MCPcopy Create free account
hub / github.com/PSOPT/psopt / main

Function main

snopt-interface/cppexamples/sntoya.cpp:79–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79int main(int argc, char **argv) {
80 snoptProblemA ToyProb;
81
82 // Allocate and initialize;
83 int n = 2;
84 int neF = 3;
85
86 int nS = 0, nInf;
87 double sInf;
88
89 double *x = new double[n];
90 double *xlow = new double[n];
91 double *xupp = new double[n];
92 double *xmul = new double[n];
93 int *xstate = new int[n];
94
95 double *F = new double[neF];
96 double *Flow = new double[neF];
97 double *Fupp = new double[neF];
98 double *Fmul = new double[neF];
99 int *Fstate = new int[neF];
100
101 int ObjRow = 0;
102 double ObjAdd = 0;
103
104 int Cold = 0, Basis = 1, Warm = 2;
105
106
107 // Set the upper and lower bounds.
108 xlow[0] = 0.0; xlow[1] = -1e20;
109 xupp[0] = 1e20; xupp[1] = 1e20;
110 xstate[0] = 0; xstate[1] = 0;
111
112 Flow[0] = -1e20; Flow[1] = -1e20; Flow[2] = -1e20;
113 Fupp[0] = 1e20; Fupp[1] = 4.0; Fupp[2] = 5.0;
114 Fmul[0] = 0; Fmul[0] = 0; Fmul[0] = 0;
115 x[0] = 1.0;
116 x[1] = 1.0;
117
118 // Load the data for ToyProb ...
119 ToyProb.initialize ("", 1); // no print file; summary on
120 ToyProb.setPrintFile ("Toy0.out"); // oh wait, i want a print file
121 ToyProb.setProbName ("Toy0");
122
123 // snopta will compute the Jacobian by finite-differences.
124 // snJac will be called to define the
125 // coordinate arrays (iAfun,jAvar,A) and (iGfun, jGvar).
126 ToyProb.setIntParameter("Derivative option", 0);
127 ToyProb.setIntParameter("Verify level ", 3);
128
129 // Solve the problem.
130 // snJac is called implicitly in this case to compute the Jacobian.
131 ToyProb.solve(Cold, neF, n, ObjAdd, ObjRow, toyusrf,
132 xlow, xupp, Flow, Fupp,
133 x, xstate, xmul, F, Fstate, Fmul,
134 nS, nInf, sInf);
135
136

Callers

nothing calls this directly

Calls 6

initializeMethod · 0.80
setPrintFileMethod · 0.80
setProbNameMethod · 0.80
setIntParameterMethod · 0.80
solveMethod · 0.80
setSpecsFileMethod · 0.80

Tested by

no test coverage detected