Next: Bibliography Up: Code Previous: Rosenbrock's optimizer   Contents

Subsections

# AMPL files

These files were NOT written be me.

## hs022

```var x {1..2};

minimize obj:
(x[1] - 2)^2 + (x[2] - 1)^2
;

subject to constr1: -x[1]^2 + x[2] >= 0;
subject to constr2: x[1] + x[2] <= 2;

let x[1] := 2;
let x[2] := 2;

#printf "optimal solution as starting point \n";
#let x[1] := 1;
#let x[2] := 1;

#solve;
#display x;
#display obj;
#display obj - 1;

write ghs022;
```

## hs023

```var x {1..2} <= 50, >= -50;

minimize obj:
x[1]^2 + x[2]^2
;

subject to constr1: x[1] + x[2] >= 1;
subject to constr2: x[1]^2 + x[2]^2 >= 1;
subject to constr3: 9*x[1]^2 + x[2]^2 >= 9;
subject to constr4: x[1]^2 - x[2] >= 0;
subject to constr5: x[2]^2 - x[1] >= 0;

let x[1] := 3;
let x[2] := 1;

#printf "optimal solution as starting point \n";
#let x[1] := 1;
#let x[2] := 1;

#solve;
#display x;
#display obj;
#display obj - 2;

write ghs023;
```

## hs026

```var x {1..3};

minimize obj:
(x[1] - x[2])^2 + (x[2] - x[3])^4
;

subject to constr1: (1 + x[2]^2)*x[1] + x[3]^4 >= 3;

let x[1] := -2.6;
let x[2] :=  2;
let x[3] :=  2;

#printf "optimal solution as starting point \n";
#let x[1] :=  1;
#let x[2] :=  1;
#let x[3] :=  1;

#display obj;
#solve;
#display x;
#display obj;
#display obj - 0;

write ghs026;
```

## hs034

```var x {1..3} >= 0;

minimize obj:
-x[1]
;

subject to constr1: x[2] >= exp(x[1]);
subject to constr2: x[3] >= exp(x[2]);
subject to constr3: x[1] <= 100;
subject to constr4: x[2] <= 100;
subject to constr5: x[3] <= 10;

let x[1] := 0;
let x[2] := 1.05;
let x[3] := 2.9;

#printf "optimal solution as starting point \n";
#let x[1] := 0.83403;
#let x[2] := 2.30258;
#let x[3] := 10;

#display obj;
#solve;
#display x;
#display obj;
#display obj + log(log(10));

write ghs034;
```

## hs038

```var x {1..4} >= -10, <= 10;

minimize obj:
100*(x[2]-x[1]^2)^2 + (1-x[1])^2 + 90*(x[4]-x[3]^2)^2 + (1-x[3])^2
+ 10.1*( (x[2]-1)^2 + (x[4]-1)^2 ) + 19.8*(x[2]-1)*(x[4]-1)
;

subject to constr1: x[1] + 2*x[2] + 2*x[3] <= 72;
subject to constr2: x[1] + 2*x[2] + 2*x[3] >= 0;

let x[1] := -3;
let x[2] := -1;
let x[3] := -3;
let x[4] := -1;

#printf "optimal solution as starting point \n";
#let x[1] := 1;
#let x[2] := 1;
#let x[3] := 1;
#let x[4] := 1;

#display obj;
#solve;
#display x;
#display obj;
#display obj - 0;

write ghs038;
```

## hs044

```var x {1..4} >= 0;

minimize obj:
x[1] - x[2] - x[3] - x[1]*x[3] + x[1]*x[4] + x[2]*x[3] - x[2]*x[4]
;

subject to constr1: x[1] + 2*x[2] <= 8;
subject to constr2: 4*x[1] + x[2] <= 12;
subject to constr3: 3*x[1] + 4*x[2] <= 12;
subject to constr4: 2*x[3] + x[4] <= 8;
subject to constr5: x[3] + 2*x[4] <= 8;
subject to constr6: x[3] + x[4] <= 5;

let x[1] := 0;
let x[2] := 0;
let x[3] := 0;
let x[4] := 0;

#printf "optimal solution as starting point \n";
#let x[1] := 0;
#let x[2] := 3;
#let x[3] := 0;
#let x[4] := 4;

#display obj;
#solve;
#display x;
#display obj;
#display obj + 15;

write ghs044;
```

## hs065

```var x {1..3};

minimize obj:
(x[1] - x[2])^2 + (x[1] + x[2] - 10)^2/9 + (x[3] - 5)^2
;

subject to constr1: x[1]^2 + x[2]^2 + x[3]^2 <= 48;
subject to constr2: -4.5 <= x[1] <= 4.5;
subject to constr3: -4.5 <= x[2] <= 4.5;
subject to constr4:   -5 <= x[3] <=   5;

let x[1] := -5;
let x[2] :=  5;
let x[3] :=  0;

#printf "optimal solution as starting point \n";
#let x[1] := 3.650461821;
#let x[2] := 3.65046168;
#let x[3] := 4.6204170507;

#display obj;
#display constr1.body, constr2.body, constr3.body;
#solve;
#display x;
#display obj;
#display obj - 0.9535288567;

write ghs065;
```

## hs076

```var x {j in 1..4} >= 0;

minimize obj:
x[1]^2 + 0.5*x[2]^2 + x[3]^2 + 0.5*x[4]^2 - x[1]*x[3] + x[3]*x[4]
- x[1] - 3*x[2] + x[3] - x[4]
;

subject to constr1: x[1] + 2*x[2] + x[3] + x[4] <= 5;
subject to constr2: 3*x[1] + x[2] + 2*x[3] - x[4] <= 4;
subject to constr3: x[2] + 4*x[3] >= 1.5;

data;

let x[1] := 0.5;
let x[2] := 0.5;
let x[3] := 0.5;
let x[4] := 0.5;

#printf "optimal solution as starting point \n";
#let x[1] := 0.2727273;
#let x[2] := 2.090909;
#let x[3] :=  -0.26e-10;
#let x[4] := 0.5454545;

data;

#solve;
#display x;
#display obj;
#display obj + 4.681818181;

write ghs076;
```

## hs100

```var x {1..7};

minimize obj:
(x[1]-10)^2 + 5*(x[2]-12)^2 + x[3]^4 + 3*(x[4]-11)^2 + 10*x[5]^6
+ 7*x[6]^2 + x[7]^4 - 4*x[6]*x[7] - 10*x[6] - 8*x[7]
;

subject to constr1: 2*x[1]^2 + 3*x[2]^4 + x[3] + 4*x[4]^2 + 5*x[5] <= 127;
subject to constr2: 7*x[1] + 3*x[2] + 10*x[3]^2 + x[4] - x[5] <= 282;
subject to constr3: 23*x[1] + x[2]^2 + 6*x[6]^2 - 8*x[7] <= 196;
subject to constr4: -4*x[1]^2 - x[2]^2 + 3*x[1]*x[2] -2*x[3]^2 - 5*x[6]
+11*x[7] >= 0;

data;

let x[1] := 1;
let x[2] := 2;
let x[3] := 0;
let x[4] := 4;
let x[5] := 0;
let x[6] := 1;
let x[7] := 1;

#printf "optimal solution as starting point \n";
#let x[1] := 2.330499;
#let x[2] := 1.951372;
#let x[3] := -0.4775414;
#let x[4] := 4.365726;
#let x[5] := 1.038131;
#let x[6] := -0.6244870;
#let x[7] := 1.594227;

#solve;
#display x;
#display obj;
#display obj - 680.6300573;

write ghs100;
```

## hs106

```# hs106.mod	LQR2-MN-8-22
# Original AMPL coding by Elena Bobrovnikova (summer 1996 at Bell Labs).

# Heat exchanger design

# Ref.: W. Hock and K. Schittkowski, Test Examples for Nonlinear Programming
# Codes.  Lecture Notes in Economics and Mathematical Systems, v. 187,
# Springer-Verlag, New York, 1981, p. 115.

# Number of variables: 8
# Number of constraints:  22
# Objective linear
# Nonlinear constraints

param N integer, := 8;
set I := 1..N;

param a >= 0;
param b >= 0;
param c >= 0;
param d >= 0;
param e >= 0;
param f >= 0;
param g >= 0;
param h >= 0;

var x{I};

minimize obj:
x[1] + x[2] + x[3];

s.t. c1: 1 - a * (x[4] + x[6]) >= 0;
s.t. c2: 1 - a * (x[5] + x[7] - x[4]) >= 0;
s.t. c3: 1 - b * (x[8] - x[5]) >= 0;
s.t. c4: x[1] * x[6] - c * x[4] - d * x[1] + e >= 0;
s.t. c5: x[2] * x[7] - f * x[5] - x[2] * x[4] + f * x[4] >= 0;
s.t. c6: x[3] * x[8] - g - x[3] * x[5] + h * x[5] >= 0;
s.t. c7: 100 <= x[1] <= 10000;
s.t. c8 {i in {2,3}}: 1000 <= x[i] <= 10000;
s.t. c9 {i in 4..8}: 10 <= x[i] <= 1000;

data;
param a := 0.0025;
param b := 0.01;
param c := 833.3325;
param d := 100;
param e := 83333.33;
param f := 1250;
param g := 1250000;
param h := 2500;

var x :=
1  5000   2  5000   3  5000   4  200   5  350   6  150   7  225   8  425;

#printf "optimal solution as starting point \n";
#var x :=
#    1  579.3167
#    2  1359.943
#    3  5110.071
#    4  182.0174
#    5  295.5985
#    6  217.9799
#    7  286.4162
#    8  395.5979
#   ;

#display obj;
#solve;
#display x;
#display obj;
#display obj - 7049.330923;

write ghs106;
```

## hs108

```var x {1..9};

minimize obj:
-.5*(x[1]*x[4]-x[2]*x[3]+x[3]*x[9]-x[5]*x[9]+x[5]*x[8]-x[6]*x[7]);

s.t. c1:  1-x[3]^2-x[4]^2>=0;
s.t. c2:  1-x[5]^2-x[6]^2>=0;
s.t. c3:  1-x[9]^2>=0;
s.t. c4:  1-x[1]^2-(x[2]-x[9])^2>=0;
s.t. c5:  1-(x[1]-x[5])^2-(x[2]-x[6])^2>=0;
s.t. c6:  1-(x[1]-x[7])^2-(x[2]-x[8])^2>=0;
s.t. c7:  1-(x[3]-x[7])^2-(x[4]-x[8])^2>=0;
s.t. c8:  1-(x[3]-x[5])^2-(x[4]-x[6])^2>=0;
s.t. c9:  1-x[7]^2-(x[8]-x[9])^2>=0;
s.t. c10: x[1]*x[4]-x[2]*x[3]>=0;
s.t. c11: x[3]*x[9]>=0;
s.t. c12: -x[5]*x[9]>=0;
s.t. c13: x[5]*x[8]-x[6]*x[7]>=0;
s.t. c14: x[9]>=0;

data;

let x[1] := 1;
let x[2] := 1;
let x[3] := 1;
let x[4] := 1;
let x[5] := 1;
let x[6] := 1;
let x[7] := 1;
let x[8] := 1;
let x[9] := 1;

#let x[1] := 0.8841292;
#let x[2] := 0.4672425;
#let x[3] := 0.03742076;
#let x[4] := 0.9992996;
#let x[5] := 0.8841292;
#let x[6] := 0.4672425;
#let x[7] := 0.03742076;
#let x[8] := 0.9992996;
#let x[9] := 0;

#display obj;
#solve;
#display x;
#display obj;
#display obj+.8660254038;

write ghs108;
```

## hs116

```# hs116.mod	LQR2-MN-13-41
# Original AMPL coding by Elena Bobrovnikova (summer 1996 at Bell Labs).

# 3-stage membrane separation

# Ref.: W. Hock and K. Schittkowski, Test Examples for Nonlinear Programming
# Codes.  Lecture Notes in Economics and Mathematical Systems, v. 187,
# Springer-Verlag, New York, 1981, p. 124.

# Number of variables: 13
# Number of constraints: 41
# Objective linear
# Nonlinear constraints

param N > 0 integer, := 13;
set I := 1 .. N;

var x {i in I} >= 0;

param a > 0;
param b > 0;
param c > 0;
param d > 0;
param e > 0;
param f > 0;

minimize obj:
x[11] + x[12] + x[13];

s.t. c1: x[3] - x[2] >= 0;
s.t. c2: x[2] - x[1] >= 0;
s.t. c3: 1 - a * x[7] + a * x[8] >= 0;
s.t. c4: x[11] + x[12] + x[13] >= 50;
s.t. c5: x[13] - b * x[10] + c * x[3] * x[10] >= 0;
s.t. c6: x[5] - d * x[2] - e * x[2] * x[5] + f * x[2]^2 >= 0;
s.t. c7: x[6] - d * x[3] - e * x[3] * x[6] + f * x[3]^2 >= 0;
s.t. c8: x[4] - d * x[1] - e * x[1] * x[4] + f * x[1]^2 >= 0;
s.t. c9: x[12] - b * x[9] + c * x[2] * x[9] >= 0;
s.t. c10: x[11] - b * x[8] + c * x[1] * x[8] >= 0;
s.t. c11: x[5] * x[7] - x[1] * x[8] - x[4] * x[7] + x[4] * x[8] >= 0;
s.t. c12: 1 - a * (x[2] * x[9] + x[5] * x[8] - x[1] * x[8] - x[6] * x[9]) -
x[5] - x[6] >= 0;
s.t. c13: x[2] * x[9] - x[3] * x[10] - x[6] * x[9] - 500 * x[2] +
500 * x[6] + x[2] * x[10] >= 0;
s.t. c14: x[2] - 0.9 - a * (x[2] * x[10] - x[3] * x[10]) >= 0;
s.t. c15: x[11] + x[12] + x[13] <= 250;

s.t. b1: 0.1 <= x[1] <= 1;
s.t. b2: 0.1 <= x[2] <= 1;
s.t. b3: 0.1 <= x[3] <= 1;
s.t. b4: 0.0001 <= x[4] <= 0.1;
s.t. b5: 0.1 <= x[5] <= 0.9;
s.t. b6: 0.1 <= x[6] <= 0.9;
s.t. b7: 0.1 <= x[7] <= 1000;
s.t. b8: 0.1 <= x[8] <= 1000;
s.t. b9: 500 <= x[9] <= 1000;
s.t. b10: 0.1 <= x[10] <= 500;
s.t. b11: 1 <= x[11] <= 150;
s.t. b12: 0.0001 <= x[12] <= 150;
s.t. b13: 0.0001 <= x[13] <= 150;

data;
param a := 0.002;
param b := 1.262626;
param c := 1.231059;
param d := 0.03475;
param e := 0.975;
param f := 0.00975;
var x :=
1 0.5  2 0.8  3 0.9  4 0.1  5 0.14  6 0.5  7 489  8 80  9 650
10 450  11 150  12 150  13 150;

#display obj;
#solve;
#display x;
#display obj;
#display obj - 97.588409;

write ghs116;
```

## hs268

```# AMPL Model by Hande Y. Benson
#
# Copyright (C) 2001 Princeton University
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that the copyright notice and this
# permission notice appear in all supporting documentation.

#   Source:
#   K. Schittkowski
#   "More Test Examples for Nonlinear Programming Codes"
#   Springer Verlag, Berlin, Lecture notes in economics and
#   mathematical systems, volume 282, 1987

#   SIF input: Michel Bierlaire and Annick Sartenaer, October 1992.
#              minor correction by Ph. Shott, Jan 1995.

#   classification QLR2-AN-5-5

param D{1..5, 1..5};
param B{1..5};
var x{1..5} := 1.0;

minimize f:
14463.0 + sum {i in 1..5, j in 1..5} D[i,j]*x[i]*x[j]
+ -2*sum {i in 1..5} (B[i]*x[i]);
subject to cons1:
-sum {i in 1..5} x[i] + 5>= 0;
subject to cons2:
10*x[1]+10*x[2]-3*x[3]+5*x[4]+4*x[5] -20 >= 0;
subject to cons3:
-8*x[1]+x[2]-2*x[3]-5*x[4]+3*x[5] + 40 >= 0;
subject to cons4:
8*x[1]-x[2]+2*x[3]+5*x[4]-3*x[5] -11>= 0;
subject to cons5:
-4*x[1]-2*x[2]+3*x[3]-5*x[4]+x[5] +30>= 0;

data;
param B:=
1	-9170
2	17099
3	-2271
4	-4336
5	-43;
param D:
1	2	3	4	5:=
1	10197	-12454	-1013	1948	329
2	-12454	20909	-1733	-4914	-186
3	-1013	-1733	1755	1089	-174
4	1948	-4914	1089	1515	-22
5	329	-186	-174	-22	27;

#
# optimal solution:
# x1= 1
# x2= 2
# x3= -1
# x4= 3
# x5= -4
#

#solve; display f; display x;

write ghs268;
```

Frank Vanden Berghen 2004-04-19