3
|
1 // NPSOL.cc -*- C++ -*- |
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
238
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #include <math.h> |
288
|
29 #include <float.h> |
287
|
30 #include <string.h> |
|
31 #include <strstream.h> |
238
|
32 |
3
|
33 #ifndef NPSOL_MISSING |
|
34 |
|
35 #include "NPSOL.h" |
|
36 #include "f77-uscore.h" |
|
37 #include "sun-utils.h" |
|
38 |
|
39 extern "C" |
|
40 { |
|
41 int F77_FCN (npoptn) (char *, long); |
|
42 |
|
43 int F77_FCN (npsol) (int *, int *, int *, int *, int *, int *, |
255
|
44 double *, double *, double *, |
|
45 int (*)(int*, int*, int*, int*, int*, double*, |
|
46 double*, double*, int*), |
|
47 int (*)(int*, int*, double*, double*, double*, int*), |
|
48 int *, int *, int *, double *, |
3
|
49 double *, double *, double *, double *, |
|
50 double *, double *, int *, int *, double *, |
287
|
51 int *); |
3
|
52 } |
|
53 |
255
|
54 // XXX FIXME XXX -- would be nice to not have to have this global |
|
55 // variable. |
|
56 // Nonzero means an error occurred in the calculation of the objective |
|
57 // function, and the user wants us to quit. |
|
58 int npsol_objective_error = 0; |
|
59 |
3
|
60 static objective_fcn user_phi; |
|
61 static gradient_fcn user_grad; |
|
62 static nonlinear_fcn user_g; |
|
63 static jacobian_fcn user_jac; |
|
64 |
|
65 int |
|
66 npsol_objfun (int *mode, int *n, double *xx, double *objf, |
287
|
67 double *objgrd, int *nstate) |
3
|
68 { |
|
69 int nn = *n; |
|
70 Vector tmp_x (nn); |
|
71 |
255
|
72 npsol_objective_error = 0; |
|
73 |
3
|
74 for (int i = 0; i < nn; i++) |
|
75 tmp_x.elem (i) = xx[i]; |
|
76 |
|
77 if (*mode == 0 || *mode == 2) |
|
78 { |
|
79 double value = (*user_phi) (tmp_x); |
255
|
80 |
|
81 if (npsol_objective_error) |
|
82 { |
|
83 *mode = -1; |
|
84 return 0; |
|
85 } |
|
86 |
3
|
87 #if defined (sun) && defined (__GNUC__) |
|
88 assign_double (objf, value); |
|
89 #else |
|
90 *objf = value; |
|
91 #endif |
|
92 } |
|
93 |
|
94 if ((*mode == 1 || *mode == 2) && user_grad != NULL) |
|
95 { |
|
96 Vector tmp_grad (nn); |
|
97 |
|
98 tmp_grad = (*user_grad) (tmp_x); |
|
99 |
255
|
100 if (tmp_grad.length () == 0) |
|
101 *mode = -1; |
|
102 else |
|
103 { |
|
104 for (i = 0; i < nn; i++) |
|
105 objgrd[i] = tmp_grad.elem (i); |
|
106 } |
3
|
107 } |
|
108 |
|
109 return 0; |
|
110 } |
|
111 |
|
112 int |
|
113 npsol_confun (int *mode, int *ncnln, int *n, int *nrowj, int *needc, |
|
114 double *xx, double *cons, double *cjac, int *nstate) |
|
115 { |
|
116 int nn = *n, nncnln = *ncnln; |
|
117 Vector tmp_x (nn); |
|
118 Vector tmp_c (nncnln); |
|
119 |
|
120 for (int i = 0; i < nn; i++) |
|
121 tmp_x.elem (i) = xx[i]; |
|
122 |
|
123 tmp_c = (*user_g) (tmp_x); |
|
124 |
255
|
125 if (tmp_c.length () == 0) |
|
126 { |
|
127 *mode = -1; |
|
128 return 0; |
|
129 } |
|
130 else |
|
131 { |
|
132 for (i = 0; i < nncnln; i++) |
|
133 cons[i] = tmp_c.elem (i); |
|
134 } |
3
|
135 |
|
136 if (user_jac != NULL) |
|
137 { |
|
138 Matrix tmp_jac (nncnln, nn); |
|
139 |
|
140 tmp_jac = (*user_jac) (tmp_x); |
|
141 |
255
|
142 if (tmp_jac.rows () == 0 || tmp_jac.columns () == 0) |
|
143 *mode = -1; |
|
144 else |
|
145 { |
|
146 int ld = *nrowj; |
|
147 for (int j = 0; j < nn; j++) |
|
148 for (i = 0; i < nncnln; i++) |
|
149 cjac[i+j*ld] = tmp_jac (i, j); |
|
150 } |
3
|
151 } |
|
152 |
|
153 return 0; |
|
154 } |
|
155 |
|
156 Vector |
|
157 NPSOL::minimize (void) |
|
158 { |
|
159 double objf; |
|
160 int inform; |
|
161 Vector lambda; |
|
162 return minimize (objf, inform, lambda); |
|
163 } |
|
164 |
|
165 Vector |
|
166 NPSOL::minimize (double& objf) |
|
167 { |
|
168 int inform; |
|
169 Vector lambda; |
|
170 return minimize (objf, inform, lambda); |
|
171 } |
|
172 |
|
173 Vector |
|
174 NPSOL::minimize (double& objf, int& inform) |
|
175 { |
|
176 Vector lambda; |
|
177 return minimize (objf, inform, lambda); |
|
178 } |
|
179 |
|
180 Vector |
|
181 NPSOL::minimize (double& objf, int& inform, Vector& lambda) |
|
182 { |
|
183 // Dimensions of various things. |
|
184 |
|
185 int n = x.capacity (); |
|
186 int nclin = lc.size (); |
|
187 int ncnln = nlc.size (); |
|
188 int nrowa = 1 > nclin ? 1 : nclin; |
|
189 int nrowj = 1 > ncnln ? 1 : ncnln; |
|
190 int nrowr = n; |
|
191 |
|
192 // Informative stuff. |
|
193 |
|
194 int iter; |
|
195 int *istate = new int [n+nclin+ncnln]; |
|
196 |
|
197 // User defined function stuff is defined above in the functions |
|
198 // npsol_confun() and npsol_objfun(); |
|
199 |
|
200 // Constraint stuff. |
|
201 |
|
202 double dummy; |
|
203 double *pclin = &dummy; |
|
204 Matrix clin; |
|
205 if (nclin > 0) |
|
206 { |
|
207 clin = lc.constraint_matrix (); |
|
208 pclin = clin.fortran_vec (); |
|
209 } |
|
210 |
|
211 double *clow = new double [n+nclin+ncnln]; |
|
212 double *cup = new double [n+nclin+ncnln]; |
|
213 |
|
214 if (bnds.size () > 0) |
|
215 { |
|
216 for (int i = 0; i < n; i++) |
|
217 { |
|
218 clow[i] = bnds.lower_bound (i); |
|
219 cup[i] = bnds.upper_bound (i); |
|
220 } |
|
221 } |
|
222 else |
|
223 { |
|
224 double huge = 1.0e30; |
|
225 for (int i = 0; i < n; i++) |
|
226 { |
|
227 clow[i] = -huge; |
|
228 cup[i] = huge; |
|
229 } |
|
230 } |
|
231 |
|
232 for (int i = 0; i < nclin; i++) |
|
233 { |
|
234 clow[i+n] = lc.lower_bound (i); |
|
235 cup[i+n] = lc.upper_bound (i); |
|
236 } |
|
237 |
|
238 for (i = 0; i < ncnln; i++) |
|
239 { |
|
240 clow[i+n+nclin] = nlc.lower_bound (i); |
|
241 cup[i+n+nclin] = nlc.upper_bound (i); |
|
242 } |
|
243 |
|
244 double *c = &dummy; |
|
245 double *cjac = &dummy; |
|
246 if (ncnln > 0) |
|
247 { |
|
248 c = new double [ncnln]; |
|
249 cjac = new double [nrowj*n]; |
|
250 } |
|
251 |
|
252 // Objective stuff. |
|
253 |
|
254 double *objgrd = new double [n]; |
|
255 |
|
256 // Other stuff. |
|
257 |
|
258 double *r = new double [n*n]; |
|
259 |
|
260 lambda.resize (n+nclin+ncnln); |
|
261 double *pclambda = lambda.fortran_vec (); |
|
262 |
|
263 // Decision variable stuff. |
|
264 |
|
265 double *px = x.fortran_vec (); |
|
266 |
|
267 // Workspace parameters. |
|
268 |
|
269 int lenw; |
|
270 int leniw = 3 * n + nclin + 2 * ncnln; |
|
271 if (nclin == 0 && ncnln == 0) |
|
272 lenw = 20*n; |
|
273 else if (ncnln == 0) |
|
274 lenw = 2*n*(10 + n) + 11*nclin; |
|
275 else |
|
276 lenw = 2*n*(n + 10) + nclin*(n + 11) + ncnln*(2*n + 21); |
|
277 |
|
278 int *iw = new int [leniw]; |
|
279 double *w = new double [lenw]; |
|
280 |
|
281 user_phi = phi.objective_function (); |
|
282 user_grad = phi.gradient_function (); |
|
283 user_g = nlc.function (); |
|
284 user_jac = nlc.jacobian_function (); |
|
285 |
287
|
286 pass_options_to_npsol (); |
3
|
287 |
|
288 if (user_jac == NULL && user_grad == NULL) |
287
|
289 F77_FCN (npoptn) ("Derivative Level 0", 18L); |
3
|
290 else if (user_jac == NULL && user_grad != NULL) |
287
|
291 F77_FCN (npoptn) ("Derivative Level 1", 18L); |
3
|
292 else if (user_jac != NULL && user_grad == NULL) |
287
|
293 F77_FCN (npoptn) ("Derivative Level 2", 18L); |
3
|
294 else if (user_jac != NULL && user_grad != NULL) |
287
|
295 F77_FCN (npoptn) ("Derivative Level 3", 18L); |
3
|
296 |
130
|
297 int attempt = 0; |
|
298 while (attempt++ < 5) |
3
|
299 { |
|
300 |
|
301 F77_FCN (npsol) (&n, &nclin, &ncnln, &nrowa, &nrowj, &nrowr, pclin, |
|
302 clow, cup, npsol_confun, npsol_objfun, &inform, |
|
303 &iter, istate, c, cjac, pclambda, &objf, objgrd, r, |
|
304 px, iw, &leniw, w, &lenw); |
|
305 |
|
306 if (inform == 6 || inform == 1) |
|
307 continue; |
|
308 else |
|
309 break; |
|
310 } |
|
311 |
|
312 // See how it went. |
|
313 |
|
314 return x; |
|
315 } |
|
316 |
|
317 Vector |
|
318 NPSOL::minimize (const Vector& xnew) |
|
319 { |
|
320 x = xnew; |
|
321 return minimize (); |
|
322 } |
|
323 |
|
324 Vector |
|
325 NPSOL::minimize (const Vector& xnew, double& objf) |
|
326 { |
|
327 x = xnew; |
|
328 return minimize (objf); |
|
329 } |
|
330 |
|
331 Vector |
|
332 NPSOL::minimize (const Vector& xnew, double& objf, int& inform) |
|
333 { |
|
334 x = xnew; |
|
335 return minimize (objf, inform); |
|
336 } |
|
337 |
|
338 Vector |
|
339 NPSOL::minimize (const Vector& xnew, double& objf, int& inform, Vector& lambda) |
|
340 { |
|
341 x = xnew; |
|
342 return minimize (objf, inform, lambda); |
|
343 } |
|
344 |
|
345 NPSOL& |
|
346 NPSOL::option (char *s) |
|
347 { |
287
|
348 cerr << "This function no longer has any effect.\n" |
|
349 << "Use the NPSOL_option class instead\n"; |
|
350 |
|
351 return *this; |
|
352 } |
|
353 |
|
354 NPSOL_options::NPSOL_options (void) |
|
355 { |
|
356 init (); |
|
357 } |
|
358 |
|
359 NPSOL_options::NPSOL_options (const NPSOL_options& opt) |
|
360 { |
|
361 copy (opt); |
|
362 } |
|
363 |
|
364 NPSOL_options& |
|
365 NPSOL_options::operator = (const NPSOL_options& opt) |
|
366 { |
|
367 if (this != &opt) |
|
368 copy (opt); |
|
369 |
3
|
370 return *this; |
|
371 } |
|
372 |
287
|
373 NPSOL_options::~NPSOL_options (void) |
|
374 { |
|
375 } |
|
376 |
|
377 void |
|
378 NPSOL_options::init (void) |
|
379 { |
|
380 x_central_difference_interval = -1.0; |
|
381 x_crash_tolerance = 0.1; |
|
382 x_difference_interval = -1.0; |
|
383 x_function_precision = pow (DBL_EPSILON, 0.9); |
|
384 x_infinite_bound = 1.0e+30; |
|
385 x_infinite_step = 1.0e+30; |
|
386 x_linear_feasibility_tolerance = sqrt (DBL_EPSILON); |
|
387 x_linesearch_tolerance = 0.9; |
|
388 x_nonlinear_feasibility_tolerance = sqrt (DBL_EPSILON); |
|
389 x_optimality_tolerance = pow (DBL_EPSILON, 0.8); |
|
390 x_derivative_level = 0; |
|
391 x_major_iteration_limit = -1; |
|
392 x_minor_iteration_limit = -1; |
|
393 x_major_print_level = 0; |
|
394 x_minor_print_level = 0; |
|
395 x_start_objective_check = 1; |
|
396 x_start_constraint_check = 1; |
|
397 x_stop_objective_check = -1; |
|
398 x_stop_constraint_check = -1; |
|
399 x_verify_level = 0; |
|
400 } |
|
401 |
|
402 void |
|
403 NPSOL_options::copy (const NPSOL_options& opt) |
|
404 { |
|
405 x_central_difference_interval = opt.x_central_difference_interval; |
|
406 x_crash_tolerance = opt.x_crash_tolerance; |
|
407 x_difference_interval = opt.x_difference_interval; |
|
408 x_function_precision = opt.x_function_precision; |
|
409 x_infinite_bound = opt.x_infinite_bound; |
|
410 x_infinite_step = opt.x_infinite_step; |
|
411 x_linear_feasibility_tolerance = opt.x_linear_feasibility_tolerance; |
|
412 x_linesearch_tolerance = opt.x_linesearch_tolerance; |
|
413 x_nonlinear_feasibility_tolerance = opt.x_nonlinear_feasibility_tolerance; |
|
414 x_optimality_tolerance = opt.x_optimality_tolerance; |
|
415 x_derivative_level = opt.x_derivative_level; |
|
416 x_major_iteration_limit = opt.x_major_iteration_limit; |
|
417 x_minor_iteration_limit = opt.x_minor_iteration_limit; |
|
418 x_major_print_level = opt.x_major_print_level; |
|
419 x_minor_print_level = opt.x_minor_print_level; |
|
420 x_start_objective_check = opt.x_start_objective_check; |
|
421 x_start_constraint_check = opt.x_start_constraint_check; |
|
422 x_stop_objective_check = opt.x_stop_objective_check; |
|
423 x_stop_constraint_check = opt.x_stop_constraint_check; |
|
424 x_verify_level = opt.x_verify_level; |
|
425 } |
|
426 |
|
427 void |
|
428 NPSOL_options::set_default_options (void) |
|
429 { |
|
430 init (); |
|
431 } |
|
432 |
|
433 /* |
|
434 * Passing invalid values to the set_* functions will result in |
|
435 * setting the default option. |
|
436 */ |
|
437 |
|
438 void |
|
439 NPSOL_options::set_central_difference_interval (double val) |
|
440 { |
|
441 x_central_difference_interval = (val > 0.0) ? val : -1.0; |
|
442 } |
|
443 |
|
444 void |
|
445 NPSOL_options::set_crash_tolerance (double val) |
|
446 { |
|
447 x_crash_tolerance = (val >= 0.0) ? val : 0.1; |
|
448 } |
|
449 |
|
450 void |
|
451 NPSOL_options::set_difference_interval (double val) |
|
452 { |
|
453 x_difference_interval = (val > 0.0) ? val : -1.0; |
|
454 } |
|
455 |
|
456 void |
|
457 NPSOL_options::set_function_precision (double val) |
|
458 { |
|
459 x_function_precision = (val > 0.0) ? val : pow (DBL_EPSILON, 0.9); |
|
460 } |
|
461 |
|
462 void |
|
463 NPSOL_options::set_infinite_bound (double val) |
|
464 { |
|
465 x_infinite_bound = (val > 0.0) ? val : 1.0e+30; |
|
466 } |
|
467 |
|
468 void |
|
469 NPSOL_options::set_infinite_step (double val) |
|
470 { |
|
471 x_infinite_step = (val > 0.0) ? val : 1.0e+30; |
|
472 } |
|
473 |
|
474 void |
|
475 NPSOL_options::set_linear_feasibility_tolerance (double val) |
|
476 { |
|
477 x_linear_feasibility_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); |
|
478 } |
|
479 |
|
480 void |
|
481 NPSOL_options::set_linesearch_tolerance (double val) |
|
482 { |
|
483 x_linesearch_tolerance = (val >= 0.0 && val < 1.0) ? val : 0.9; |
|
484 } |
|
485 |
|
486 void |
|
487 NPSOL_options::set_nonlinear_feasibility_tolerance (double val) |
|
488 { |
|
489 x_nonlinear_feasibility_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); |
|
490 } |
|
491 |
|
492 void |
|
493 NPSOL_options::set_optimality_tolerance (double val) |
|
494 { |
|
495 x_optimality_tolerance = (val > 0.0) ? val : pow (DBL_EPSILON, 0.8); |
|
496 } |
|
497 |
|
498 void |
|
499 NPSOL_options::set_derivative_level (int val) |
|
500 { |
|
501 x_derivative_level = (val >= 0 && val < 4) ? val : 0; |
|
502 } |
|
503 |
|
504 void |
|
505 NPSOL_options::set_major_iteration_limit (int val) |
|
506 { |
|
507 x_major_iteration_limit = (val > 0) ? val : -1; |
|
508 } |
|
509 |
|
510 void |
|
511 NPSOL_options::set_minor_iteration_limit (int val) |
|
512 { |
|
513 x_minor_iteration_limit = (val > 0) ? val : -1; |
|
514 } |
|
515 |
|
516 void |
|
517 NPSOL_options::set_major_print_level (int val) |
|
518 { |
|
519 x_major_print_level = (val >= 0) ? val : -1; |
|
520 } |
|
521 |
|
522 void |
|
523 NPSOL_options::set_minor_print_level (int val) |
|
524 { |
|
525 x_minor_print_level = (val >= 0) ? val : -1; |
|
526 } |
|
527 |
|
528 void |
|
529 NPSOL_options::set_start_objective_check (int val) |
|
530 { |
|
531 x_start_objective_check = (val >= 0) ? val : -1; |
|
532 } |
|
533 |
|
534 void |
|
535 NPSOL_options::set_start_constraint_check (int val) |
|
536 { |
|
537 x_start_constraint_check = (val >= 0) ? val : -1; |
|
538 } |
|
539 |
|
540 void |
|
541 NPSOL_options::set_stop_objective_check (int val) |
|
542 { |
|
543 x_stop_objective_check = (val >= 0) ? val : -1; |
|
544 } |
|
545 |
3
|
546 void |
287
|
547 NPSOL_options::set_stop_constraint_check (int val) |
|
548 { |
|
549 x_stop_constraint_check = (val >= 0) ? val : -1; |
|
550 } |
|
551 |
|
552 void |
|
553 NPSOL_options::set_verify_level (int val) |
|
554 { |
|
555 x_verify_level = ((val > -1 && val < 4) || (val > 9 && val < 14)) ? val : 0; |
|
556 } |
|
557 |
|
558 double |
|
559 NPSOL_options::central_difference_interval (void) const |
|
560 { |
|
561 return x_central_difference_interval; |
|
562 } |
|
563 |
|
564 double |
|
565 NPSOL_options::crash_tolerance (void) const |
|
566 { |
|
567 return x_crash_tolerance; |
|
568 } |
|
569 |
|
570 double |
|
571 NPSOL_options::difference_interval (void) const |
|
572 { |
|
573 return x_difference_interval; |
|
574 } |
|
575 |
|
576 double |
|
577 NPSOL_options::function_precision (void) const |
|
578 { |
|
579 return x_function_precision; |
|
580 } |
|
581 |
|
582 double |
|
583 NPSOL_options::infinite_bound (void) const |
|
584 { |
|
585 return x_infinite_bound; |
|
586 } |
|
587 |
|
588 double |
|
589 NPSOL_options::infinite_step (void) const |
|
590 { |
|
591 return x_infinite_step; |
|
592 } |
|
593 |
|
594 double |
|
595 NPSOL_options::linear_feasibility_tolerance (void) const |
|
596 { |
|
597 return x_linear_feasibility_tolerance; |
|
598 } |
|
599 |
|
600 double |
|
601 NPSOL_options::linesearch_tolerance (void) const |
|
602 { |
|
603 return x_linesearch_tolerance; |
|
604 } |
|
605 |
|
606 double |
|
607 NPSOL_options::nonlinear_feasibility_tolerance (void) const |
|
608 { |
|
609 return x_nonlinear_feasibility_tolerance; |
|
610 } |
|
611 |
|
612 double |
|
613 NPSOL_options::optimality_tolerance (void) const |
|
614 { |
|
615 return x_optimality_tolerance; |
|
616 } |
|
617 |
|
618 int |
|
619 NPSOL_options::derivative_level (void) const |
|
620 { |
|
621 return x_derivative_level; |
|
622 } |
|
623 |
|
624 int |
|
625 NPSOL_options::major_iteration_limit (void) const |
|
626 { |
|
627 return x_major_iteration_limit; |
|
628 } |
|
629 |
|
630 int |
|
631 NPSOL_options::minor_iteration_limit (void) const |
|
632 { |
|
633 return x_minor_iteration_limit; |
|
634 } |
|
635 |
|
636 int |
|
637 NPSOL_options::major_print_level (void) const |
|
638 { |
|
639 return x_major_print_level; |
|
640 } |
|
641 |
|
642 int |
|
643 NPSOL_options::minor_print_level (void) const |
|
644 { |
|
645 return x_minor_print_level; |
|
646 } |
|
647 |
|
648 int |
|
649 NPSOL_options::start_objective_check (void) const |
|
650 { |
|
651 return x_start_objective_check; |
|
652 } |
|
653 |
|
654 int |
|
655 NPSOL_options::start_constraint_check (void) const |
|
656 { |
|
657 return x_start_constraint_check; |
|
658 } |
|
659 |
|
660 int |
|
661 NPSOL_options::stop_objective_check (void) const |
|
662 { |
|
663 return x_stop_objective_check; |
|
664 } |
|
665 |
|
666 int |
|
667 NPSOL_options::stop_constraint_check (void) const |
|
668 { |
|
669 return x_stop_constraint_check; |
|
670 } |
|
671 |
|
672 int |
|
673 NPSOL_options::verify_level (void) const |
|
674 { |
|
675 return x_verify_level; |
|
676 } |
|
677 |
|
678 void |
|
679 NPSOL_options::pass_options_to_npsol (void) |
3
|
680 { |
|
681 F77_FCN (npoptn) ("Nolist", 6L); |
|
682 F77_FCN (npoptn) ("Defaults", 8L); |
287
|
683 |
|
684 if (x_central_difference_interval > 0.0) |
|
685 set_option ("Central Difference", x_central_difference_interval); |
|
686 |
|
687 set_option ("Crash Tolerance", x_crash_tolerance); |
|
688 |
|
689 if (x_difference_interval > 0.0) |
|
690 set_option ("Difference Interval", x_difference_interval); |
|
691 |
|
692 set_option ("Function Precision", x_function_precision); |
|
693 |
|
694 set_option ("Infinite Bound", x_infinite_bound); |
|
695 |
|
696 set_option ("Infinite Step", x_infinite_step); |
|
697 |
|
698 set_option ("Linear Feasibility", x_linear_feasibility_tolerance); |
|
699 |
|
700 set_option ("Linesearch Tolerance", x_linesearch_tolerance); |
|
701 |
|
702 set_option ("Nonlinear Feasibility", x_nonlinear_feasibility_tolerance); |
|
703 |
|
704 set_option ("Optimality Tolerance", x_optimality_tolerance); |
|
705 |
|
706 set_option ("Derivative Level", x_derivative_level); |
|
707 |
|
708 if (x_major_iteration_limit > 0) |
|
709 set_option ("Major Iteration", x_major_iteration_limit); |
|
710 |
|
711 if (x_minor_iteration_limit > 0) |
|
712 set_option ("Minor Iteration", x_minor_iteration_limit); |
|
713 |
|
714 set_option ("Major Print", x_major_print_level); |
|
715 |
|
716 set_option ("Minor Print", x_minor_print_level); |
|
717 |
|
718 set_option ("Start Objective", x_start_objective_check); |
|
719 |
|
720 set_option ("Start Constraint", x_start_constraint_check); |
|
721 |
|
722 if (x_stop_objective_check > 0) |
|
723 set_option ("Stop Objective", x_stop_objective_check); |
|
724 |
|
725 if (x_stop_constraint_check > 0) |
|
726 set_option ("Stop Constraint", x_stop_constraint_check); |
|
727 |
|
728 set_option ("Verify Level", x_verify_level); |
|
729 } |
|
730 |
|
731 void |
|
732 NPSOL_options::set_option (const char *key, int opt) |
|
733 { |
|
734 ostrstream buf; |
|
735 buf << key << " " << opt << ends; |
|
736 char *command = buf.str (); |
|
737 size_t len = strlen (command); |
|
738 F77_FCN (npoptn) (command, (long) len); |
|
739 delete [] command; |
|
740 } |
|
741 |
|
742 void |
|
743 NPSOL_options::set_option (const char *key, double opt) |
|
744 { |
|
745 ostrstream buf; |
|
746 buf << key << " " << opt << ends; |
|
747 char *command = buf.str (); |
|
748 size_t len = strlen (command); |
|
749 F77_FCN (npoptn) (command, (long) len); |
|
750 delete [] command; |
3
|
751 } |
|
752 |
|
753 #endif /* NPSOL_MISSING */ |
|
754 |
|
755 /* |
|
756 ;;; Local Variables: *** |
|
757 ;;; mode: C++ *** |
|
758 ;;; page-delimiter: "^/\\*" *** |
|
759 ;;; End: *** |
|
760 */ |