Skip to content

Commit 9be94fb

Browse files
author
Christos Efstathiou
committed
Simple Examples Synced
1 parent 0979f08 commit 9be94fb

File tree

6 files changed

+190
-32
lines changed

6 files changed

+190
-32
lines changed

simple_examples/baseresults/a00aaje.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Implementation title: Linux, 64-bit, Intel C/C++ (32-bit integers)
66
Precision: double precision
77
Product Code: CLL6I262CL
8-
Mark: 27.2.0 (self-contained)
8+
Mark: 27.3.0 (self-contained)
99

1010
*** End of NAG Library implementation details ***
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
E04KFJ Example Program Results
2+
3+
E04KF, First order method for bound-constrained problems
4+
Begin of Options
5+
Print File = 6 * d
6+
Print Level = 1 * U
7+
Print Options = Yes * d
8+
Print Solution = All * U
9+
Monitoring File = 9 * U
10+
Monitoring Level = 3 * U
11+
Foas Monitor Frequency = 0 * d
12+
Foas Print Frequency = 5 * U
13+
14+
Infinite Bound Size = 1.00000E+20 * d
15+
Task = Minimize * d
16+
Stats Time = No * d
17+
Time Limit = 1.00000E+06 * d
18+
Verify Derivatives = No * d
19+
20+
Foas Estimate Derivatives = No * d
21+
Foas Finite Diff Interval = 1.05367E-08 * d
22+
Foas Iteration Limit = 10000000 * d
23+
Foas Memory = 11 * d
24+
Foas Progress Tolerance = 1.08158E-12 * d
25+
Foas Rel Stop Tolerance = 1.08158E-12 * d
26+
Foas Restart Factor = 6.00000E+00 * d
27+
Foas Slow Tolerance = 1.01316E-02 * d
28+
Foas Stop Tolerance = 1.00000E-06 * d
29+
Foas Tolerance Norm = Infinity * d
30+
End of Options
31+
32+
33+
Status: converged, an optimal solution was found
34+
Value of the objective 4.00000E-02
35+
Norm of inactive gradient 0.00000E+00
36+
Norm of projected direction 0.00000E+00
37+
38+
Primal variables:
39+
idx Lower bound Value Upper bound
40+
1 -1.00000E+00 8.00000E-01 8.00000E-01
41+
2 -2.00000E+00 6.40000E-01 2.00000E+00
42+
43+
Box bounds dual variables:
44+
idx Lower bound Value Upper bound Value
45+
1 -1.00000E+00 0.00000E+00 8.00000E-01 4.00000E-01
46+
2 -2.00000E+00 0.00000E+00 2.00000E+00 0.00000E+00
47+
48+
49+
Solution found:
50+
Objective function value at solution: 4.0E-02
51+
Gradient at solution: -4.0E-01 0.0E+00
52+
53+
Estimated Lagrange multipliers: blx 0.0E+00 0.0E+00
54+
Estimated Lagrange multipliers: bux 4.0E-01 0.0E+00
55+

simple_examples/baseresults/outputexample.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Implementation title: Linux, 64-bit, Intel C/C++ or Intel Fortran
44
Precision: double precision
55
Product Code: NLL6I27DBL
6-
Mark: 27.2.0 (self-contained)
6+
Mark: 27.3.0 (self-contained)
77

88
This is a 64-bit library using 32-bit integers.
99

simple_examples/data/testdir/testtmp2.d

Lines changed: 0 additions & 7 deletions
This file was deleted.

simple_examples/data/tmptest.d

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import com.nag.routines.E04.E04RA;
2+
import com.nag.routines.E04.E04RH;
3+
import com.nag.routines.E04.E04RG;
4+
import com.nag.routines.E04.E04ZM;
5+
import com.nag.routines.E04.E04KF;
6+
import com.nag.routines.E04.E04KFU;
7+
import com.nag.routines.E04.E04RX;
8+
import com.nag.routines.E04.E04RZ;
9+
import com.nag.routines.X04.X04AC;
10+
11+
import java.lang.Math;
12+
13+
/**
14+
* E04KF example program text.
15+
*/
16+
public class E04KFJE {
17+
18+
private static final int NMONIT = 9;
19+
private static final int NVAR = 2;
20+
21+
public static void main(String[] args) {
22+
23+
long cpuser = 0;
24+
int nu = 2 * NVAR;
25+
26+
/* Header */
27+
System.out.println(" E04KFJ Example Program Results\n");
28+
29+
// Define filename for monitoring output
30+
X04AC x04ac = new X04AC();
31+
int ifail = 0;
32+
x04ac.eval(NMONIT, "e04kffe.mon", 1, ifail);
33+
34+
// Initialize handle
35+
E04RA e04ra = new E04RA();
36+
long handle = 0;
37+
ifail = 0;
38+
e04ra.eval(handle, NVAR, ifail);
39+
handle = e04ra.getHANDLE();
40+
41+
// Define initial guess point
42+
double[] x = new double[] { -1.5, 1.9 };
43+
44+
// Define Simple box bounds on X
45+
E04RH e04rh = new E04RH();
46+
double[] blx = new double[] { -1.0, -2.0 };
47+
double[] bux = new double[] { 0.8, 2.0 };
48+
ifail = 0;
49+
e04rh.eval(handle, NVAR, blx, bux, ifail);
50+
51+
// Add nonlinear objective information
52+
E04RG e04rg = new E04RG();
53+
int iidx[] = new int[NVAR];
54+
for (int i = 0; i < NVAR; i++)
55+
iidx[i] = i + 1;
56+
ifail = 0;
57+
e04rg.eval(handle, NVAR, iidx, ifail);
58+
59+
// Add options
60+
E04ZM e04zm = new E04ZM();
61+
ifail = 0;
62+
e04zm.eval(handle, "FOAS Print Frequency = 5", ifail);
63+
64+
ifail = 0;
65+
e04zm.eval(handle, "Print Solution = yes", ifail);
66+
67+
ifail = 0;
68+
e04zm.eval(handle, "Print Level = 1", ifail);
69+
70+
ifail = 0;
71+
e04zm.eval(handle, "Monitoring File = " + NMONIT, ifail);
72+
73+
ifail = 0;
74+
e04zm.eval(handle, "Monitoring Level = 3", ifail);
75+
76+
// Solve the problem
77+
E04KF e04kf = new E04KF();
78+
OBJFUN objfun = new OBJFUN();
79+
OBJGRD objgrd = new OBJGRD();
80+
MONIT monit = new MONIT();
81+
double[] rinfo = new double[100];
82+
double[] stats = new double[100];
83+
int[] iuser = new int[0];
84+
double[] ruser = new double[0];
85+
ifail = -1;
86+
e04kf.eval(handle, objfun, objgrd, monit, NVAR, x, rinfo, stats, iuser, ruser, cpuser, ifail);
87+
88+
ifail = e04kf.getIFAIL();
89+
90+
// Print objective value at solution
91+
if ((ifail == 0) || (ifail == 50)) {
92+
System.out.printf("\n\n Solution found:\n Objective function value at solution: %9.1E\n", rinfo[0]);
93+
// Retrieve Lagrange multipliers (FDX)
94+
E04RX e04rx = new E04RX();
95+
double[] u = new double[nu];
96+
e04rx.eval(handle, "U", 1, nu, u, ifail);
97+
if (ifail == 0) {
98+
System.out.printf(" Gradient at solution: %9.1E %9.1E\n\n", u[0] - u[1], u[2] - u[3]);
99+
System.out.printf(" Estimated Lagrange multipliers: blx %9.1E %9.1E\n", u[0], u[2]);
100+
System.out.printf(" Estimated Lagrange multipliers: bux %9.1E %9.1E\n", u[1], u[3]);
101+
}
102+
}
103+
104+
System.out.println();
105+
106+
// Clean up
107+
E04RZ e04rz = new E04RZ();
108+
ifail = 0;
109+
e04rz.eval(handle, ifail);
110+
}
111+
112+
public static class OBJFUN extends E04KF.Abstract_E04KF_OBJFUN {
113+
public void eval() {
114+
// Rosenbrock function
115+
this.FX = Math.pow(1.0 - this.X[0], 2) + 100.0 * Math.pow(this.X[1] - Math.pow(this.X[0], 2), 2);
116+
}
117+
}
118+
119+
public static class OBJGRD extends E04KF.Abstract_E04KF_OBJGRD {
120+
public void eval() {
121+
this.FDX[0] = 2.0 * this.X[0] - 400.0 * this.X[0] * (this.X[1] - Math.pow(this.X[0], 2)) - 2.0;
122+
this.FDX[1] = 200.0 * (this.X[1] - Math.pow(this.X[0], 2));
123+
}
124+
}
125+
126+
public static class MONIT extends E04KF.Abstract_E04KF_MONIT {
127+
public void eval() {
128+
E04KFU e04kfu = new E04KFU();
129+
e04kfu.eval(this.NVAR, this.X, this.INFORM, this.RINFO, this.STATS, this.IUSER, this.RUSER, this.CPUSER);
130+
this.INFORM = e04kfu.getINFORM();
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)