56 #include "../integrator/hydroscal_model.hpp" 62 void ffcn_model(
double *x,
double *f,
void *user_data ){
65 double *xd =
new double[
NXD];
66 double *xa =
new double[
NXA];
67 double *u =
new double[
NU];
68 double *p =
new double[
NP];
70 for( i = 0; i <
NXD; i++ ) xd[i] = x[ 1+i ];
71 for( i = 0; i <
NXA; i++ ) xa[i] = x[ NXD+1+i ];
72 for( i = 0; i <
NU; i++ ) u[i] = x[ NXA+NXD+1+i ];
73 for( i = 0; i <
NP; i++ ) p[i] = x[ NXA+NXD+NU+1+i ];
75 ffcn( &x[0], xd, xa, u, p, f );
76 gfcn( &x[0], xd, xa, u, p, &(f[NXD]) );
89 double clock1 = clock();
104 for (i=0; i <
NXD; ++i) is(1+i) = x(i);
105 for (i=0; i <
NXA; ++i) is(1+NXD+i) = z(i);
106 for (i=0; i <
NU; ++i) is(1+NXD+NXA+i) = u(i);
107 for (i=0; i <
NP; ++i) is(1+NXD+NXA+NU+i) = p(i);
115 f << hydroscalModel(is);
120 double xd[
NXD] = { 2.1936116177990631E-01,
121 3.3363028623863722E-01,
122 3.7313133250625952E-01,
123 3.9896472354654333E-01,
124 4.1533719381260475E-01,
125 4.2548399372287182E-01,
127 4.3168379354213621E-01,
128 4.3543569751236455E-01,
129 4.3768918647214428E-01,
130 4.3903262905928286E-01,
131 4.3982597315656735E-01,
132 4.4028774979047969E-01,
133 4.4055002518902953E-01,
134 4.4069238917008052E-01,
135 4.4076272408112094E-01,
136 4.4078980543461005E-01,
137 4.4079091412311144E-01,
138 4.4077642312834125E-01,
139 4.4075255679998443E-01,
140 4.4072304911231042E-01,
141 4.4069013958173919E-01,
142 6.7041926189645151E-01,
143 7.3517997375758948E-01,
144 7.8975978943631409E-01,
145 8.3481725159539033E-01,
146 8.7125377077380739E-01,
147 9.0027275078767721E-01,
148 9.2312464536394301E-01,
149 9.4096954980798608E-01,
150 9.5481731262797742E-01,
151 9.6551271145368878E-01,
152 9.7374401773010488E-01,
153 9.8006186072166701E-01,
154 9.8490109485675337E-01,
155 9.8860194771099286E-01,
156 9.9142879342008328E-01,
157 9.9358602331847468E-01,
158 9.9523105632238640E-01,
159 9.9648478785701988E-01,
160 9.9743986301741971E-01,
161 9.9816716097314861E-01,
162 9.9872084014280071E-01,
163 3.8633811956730968E+00,
164 3.9322260498028840E+00,
165 3.9771965626392531E+00,
166 4.0063070333869728E+00,
167 4.0246026844143410E+00,
168 4.0358888958821835E+00,
169 4.0427690398786789E+00,
170 4.0469300433477020E+00,
171 4.0494314648020326E+00,
172 4.0509267560029381E+00,
173 4.0518145583397631E+00,
174 4.0523364846379799E+00,
175 4.0526383977460299E+00,
176 4.0528081437632766E+00,
177 4.0528985491134542E+00,
178 4.0529413510270169E+00,
179 4.0529556049324462E+00,
180 4.0529527471448805E+00,
181 4.0529396392278008E+00,
182 4.0529203970496912E+00,
183 3.6071164950918582E+00,
184 3.7583754503438387E+00,
185 3.8917148481441974E+00,
186 4.0094300698741563E+00,
187 4.1102216725798293E+00,
188 4.1944038520620675E+00,
189 4.2633275166560596E+00,
190 4.3188755452109175E+00,
191 4.3630947909857642E+00,
192 4.3979622247841386E+00,
193 4.4252580012497740E+00,
194 4.4465128947193868E+00,
195 4.4630018314791968E+00,
196 4.4757626150015568E+00,
197 4.4856260094946823E+00,
198 4.4932488551808500E+00,
199 4.4991456959629330E+00,
200 4.5037168116896273E+00,
201 4.5072719605639726E+00,
202 4.5100498969782414E+00
205 double ud[
NU] = { 4.1833910982822058E+00,
206 2.4899344742988991E+00
209 double pd[
NP] = { 1.5458567140000001E-01,
210 1.7499999999999999E-01,
211 3.4717208398678062E-01,
212 6.1895708603484367E-01,
213 1.6593025789999999E-01,
214 5.0695122527590109E-01,
215 8.5000000000000000E+00,
216 1.7000000000000001E-01,
217 9.3885430857029321E+04,
218 2.5000000000000000E+02,
219 1.4026000000000000E+01,
220 3.2000000000000001E-01,
221 7.1054000000000002E+01,
222 4.7163089489100003E+01,
223 4.1833910753991770E+00,
224 2.4899344810136301E+00,
225 1.8760537088149468E+02
234 OCP ocp( t_start, t_end, intervals );
244 h << 0.1 * ( z(94) - 88.0 );
245 h << 0.1 * ( z(108) - 70.0 );
246 h << 0.01 * ( u(0) - ud[0] );
247 h << 0.01 * ( u(1) - ud[1] );
260 ocp.
subjectTo( ud[0] - 2.0 <= u(0) <= ud[0] + 2.0 );
261 ocp.
subjectTo( ud[1] - 2.0 <= u(1) <= ud[1] + 2.0 );
290 double clock2 = clock();
291 printf(
"total computation time = %.16e \n", (clock2-clock1)/CLOCKS_PER_SEC );
309 window.
addSubplot( out_algstates(94),
"Temperature tray 14" );
310 window.
addSubplot( out_algstates(108),
"Temperature tray 28" );
311 window.
addSubplot( out_controls(0),
"L_vol" );
returnValue print(std::ostream &stream=std::cout, const char *const name=DEFAULT_LABEL, const char *const startString=DEFAULT_START_STRING, const char *const endString=DEFAULT_END_STRING, uint width=DEFAULT_WIDTH, uint precision=DEFAULT_PRECISION, const char *const colSeparator=DEFAULT_COL_SEPARATOR, const char *const rowSeparator=DEFAULT_ROW_SEPARATOR) const
USING_NAMESPACE_ACADO void ffcn_model(double *x, double *f, void *user_data)
Allows to setup and evaluate a general function based on SymbolicExpressions.
virtual returnValue plot(PlotFrequency _frequency=PLOT_IN_ANY_CASE)
User-interface to formulate and solve optimal control problems and static NLPs.
#define USING_NAMESPACE_ACADO
Provides a time grid consisting of vector-valued optimization variables at each grid point...
returnValue subjectTo(const DifferentialEquation &differentialEquation_)
returnValue addSubplot(PlotWindowSubplot &_subplot)
returnValue getAlgebraicStates(VariablesGrid &xa_) const
returnValue set(OptionsName name, int value)
returnValue minimizeLSQ(const DMatrix &S, const Function &h, const DVector &r)
static void gfcn(double *t, double *xd, double *xa, double *u, double *p, double *rhs)
Data class for defining optimal control problems.
static void ffcn(double *t, double *xd, double *xa, double *u, double *p, double *rhs)
returnValue getControls(VariablesGrid &p_) const
returnValue initializeAlgebraicStates(const char *fileName, BooleanType autoinit=BT_FALSE)
Provides an interface to Gnuplot for plotting algorithmic outputs.
virtual returnValue solve()
returnValue getDifferentialStates(VariablesGrid &xd_) const
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.