annotate src/npsol.cc @ 296:3c23b8ea9099

[project @ 1994-01-17 02:49:15 by jwe]
author jwe
date Mon, 17 Jan 1994 02:54:02 +0000
parents 6027a905fc06
children 4481fdfb01b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
d68036bcad4c [project @ 1993-08-08 03:53:43 by jwe]
jwe
parents: 1
diff changeset
1 // f-npsol.cc -*- C++ -*-
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
3
296
3c23b8ea9099 [project @ 1994-01-17 02:49:15 by jwe]
jwe
parents: 287
diff changeset
4 Copyright (C) 1993, 1994 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11 later version.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, write to the Free
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 215
diff changeset
24 #ifdef HAVE_CONFIG_H
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 215
diff changeset
25 #include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28 #ifndef NPSOL_MISSING
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
30 #include <strstream.h>
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
31
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
32 #include "NPSOL.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
33
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
34 #include "tree-const.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
35 #include "variables.h"
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
36 #include "builtins.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37 #include "gripes.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38 #include "error.h"
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
39 #include "pager.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
40 #include "utils.h"
7
d68036bcad4c [project @ 1993-08-08 03:53:43 by jwe]
jwe
parents: 1
diff changeset
41 #include "f-npsol.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
42
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
43 // Global pointers for user defined functions required by npsol.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
44 static tree *npsol_objective;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 static tree *npsol_constraints;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
47 #ifdef WITH_DLD
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48 tree_constant *
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
49 builtin_npsol_2 (const tree_constant *args, int nargin, int nargout)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
50 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51 return npsol (args, nargin, nargout);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
52 }
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
53
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
54 tree_constant *
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
55 builtin_npsol_options_2 (const tree_constant *args, int nargin, int nargout)
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
56 {
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
57 return npsol_options (args, nargin, nargout);
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
58 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
61 static NPSOL_options npsol_opts;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
62
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
63 double
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
64 npsol_objective_function (const ColumnVector& x)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
65 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
66 int n = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
67
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
68 tree_constant decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
69 if (n > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
71 Matrix m (n, 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
72 for (int i = 0; i < n; i++)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
73 m (i, 0) = x.elem (i);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74 decision_vars = tree_constant (m);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
75 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
76 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
77 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
78 double d = x.elem (0);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
79 decision_vars = tree_constant (d);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
80 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
81
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
82 // tree_constant name = tree_constant (npsol_objective->name ());
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
83 tree_constant *args = new tree_constant [2];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
84 // args[0] = name;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
85 args[1] = decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
86
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
87 static double retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
88 retval = 0.0;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
89
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
90 tree_constant objective_value;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
91 if (npsol_objective != NULL_TREE)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
92 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
93 tree_constant *tmp = npsol_objective->eval (args, 2, 1, 0);
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
94
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
95 delete [] args;
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
96
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
97 if (error_state)
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
98 {
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
99 error ("npsol: error evaluating objective function");
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
100 npsol_objective_error = 1; // XXX FIXME XXX
260
74d73a4b3fc7 [project @ 1993-12-14 23:57:42 by jwe]
jwe
parents: 255
diff changeset
101 delete [] tmp;
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
102 return retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
103 }
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
104
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
105 if (tmp != NULL_TREE_CONST && tmp[0].is_defined ())
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
106 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
107 objective_value = tmp[0];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
108 delete [] tmp;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
109 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
110 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
111 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
112 delete [] tmp;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
113 error ("npsol: error evaluating objective function");
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
114 npsol_objective_error = 1; // XXX FIXME XXX
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
115 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
116 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
117 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
118
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
119 switch (objective_value.const_type ())
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
120 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
121 case tree_constant_rep::matrix_constant:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
122 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
123 Matrix m = objective_value.matrix_value ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124 if (m.rows () == 1 && m.columns () == 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 retval = m.elem (0, 0);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126 else
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
127 {
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
128 gripe_user_returned_invalid ("npsol_objective");
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
129 npsol_objective_error = 1; // XXX FIXME XXX
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
130 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
131 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
132 break;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
133 case tree_constant_rep::scalar_constant:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
134 retval = objective_value.double_value ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
135 break;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
136 default:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
137 gripe_user_returned_invalid ("npsol_objective");
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
138 npsol_objective_error = 1; // XXX FIXME XXX
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
139 break;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
140 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
141
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
142 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
143 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
144
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
145 ColumnVector
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
146 npsol_constraint_function (const ColumnVector& x)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
147 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
148 ColumnVector retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
149
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
150 int n = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
151
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
152 tree_constant decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
153 if (n > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
154 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
155 Matrix m (n, 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
156 for (int i = 0; i < n; i++)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
157 m (i, 0) = x.elem (i);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
158 decision_vars = tree_constant (m);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
159 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
160 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
161 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
162 double d = x.elem (0);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
163 decision_vars = tree_constant (d);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
164 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
165
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
166 // tree_constant name = tree_constant (npsol_constraints->name ());
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
167 tree_constant *args = new tree_constant [2];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
168 // args[0] = name;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
169 args[1] = decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
170
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
171 if (npsol_constraints != NULL_TREE)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
172 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
173 tree_constant *tmp = npsol_constraints->eval (args, 2, 1, 0);
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
174
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
175 delete [] args;
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
176
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
177 if (error_state)
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
178 {
260
74d73a4b3fc7 [project @ 1993-12-14 23:57:42 by jwe]
jwe
parents: 255
diff changeset
179 delete [] tmp;
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
180 error ("npsol: error evaluating constraints");
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
181 return retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
182 }
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
183
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
184 if (tmp != NULL_TREE_CONST && tmp[0].is_defined ())
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
185 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
186 retval = tmp[0].to_vector ();
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
187
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
188 delete [] tmp;
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
189
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
190 if (retval.length () <= 0)
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
191 error ("npsol: error evaluating constraints");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
192 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
193 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
194 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
195 delete [] tmp;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
196 error ("npsol: error evaluating constraints");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
197 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
198 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
199
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
200 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
201 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
202
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
203 int
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
204 linear_constraints_ok (const ColumnVector& x, const ColumnVector& llb,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
205 const Matrix& c, const ColumnVector& lub,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
206 char *warn_for, int warn)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
207 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
208 int x_len = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
209 int llb_len = llb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
210 int lub_len = lub.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
211 int c_rows = c.rows ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
212 int c_cols = c.columns ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
213
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
214 int ok = 1;
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
215 if (warn)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
216 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
217 if (c_rows == 0 || c_cols == 0 || llb_len == 0 || lub_len == 0)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
218 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
219 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
220 error ("%s: linear constraints must have nonzero dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
221 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
222 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
223 else if (x_len != c_cols || llb_len != lub_len || llb_len != c_rows)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
224 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
225 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
226 error ("%s: linear constraints have inconsistent dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
227 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
228 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
229 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
230
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
231 return ok;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
232 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
233
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
234 int
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
235 nonlinear_constraints_ok (const ColumnVector& x, const ColumnVector& nllb,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
236 nonlinear_fcn g, const ColumnVector& nlub,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
237 char *warn_for, int warn)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
238 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
239 int nllb_len = nllb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
240 int nlub_len = nlub.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
241 ColumnVector c = (*g) (x);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
242 int c_len = c.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
243
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
244 int ok = 1;
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
245 if (warn)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
246 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
247 if (nllb_len == 0 || nlub_len == 0 || c_len == 0)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
248 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
249 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
250 error ("%s: nonlinear constraints have nonzero dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
251 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
252 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
253 else if (nllb_len != nlub_len || nllb_len != c_len)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
254 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
255 ok = 0;
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
256 error ("%s: nonlinear constraints have inconsistent dimensions",
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
257 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
258 }
135
7aea883afd29 [project @ 1993-09-29 16:15:12 by jwe]
jwe
parents: 132
diff changeset
259 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
260 return ok;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
261 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
262
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
263 tree_constant *
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
264 npsol (const tree_constant *args, int nargin, int nargout)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
265 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
266 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
267
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268 Handle all of the following:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
269
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
270 1. npsol (x, phi)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271 2. npsol (x, phi, lb, ub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
272 3. npsol (x, phi, lb, ub, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
273 4. npsol (x, phi, lb, ub, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
274 5. npsol (x, phi, lb, ub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
275 6. npsol (x, phi, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
276 7. npsol (x, phi, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
277 8. npsol (x, phi, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
278
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
279 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
280
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
281 // Assumes that we have been given the correct number of arguments.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
282
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
283 tree_constant *retval = NULL_TREE_CONST;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
284
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
285 ColumnVector x = args[1].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
286
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
287 if (x.capacity () == 0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
288 {
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
289 error ("npsol: expecting vector as first argument");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
290 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
291 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
292
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
293 npsol_objective = is_valid_function (args[2], "npsol", 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
294 if (npsol_objective == NULL_TREE
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
295 || takes_correct_nargs (npsol_objective, 2, "npsol", 1) != 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
296 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
297
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
298 Objective func (npsol_objective_function);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
299
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
300 ColumnVector soln;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
301
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
302 Bounds bounds;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
303 if (nargin == 5 || nargin == 8 || nargin == 11)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
304 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
305 ColumnVector lb = args[3].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
306 ColumnVector ub = args[4].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
307
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
308 int lb_len = lb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309 int ub_len = ub.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
310 if (lb_len != ub_len || lb_len != x.capacity ())
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
311 {
214
1468a5e6a466 [project @ 1993-11-13 04:04:32 by jwe]
jwe
parents: 162
diff changeset
312 error ("npsol: lower and upper bounds and decision variable vector");
1468a5e6a466 [project @ 1993-11-13 04:04:32 by jwe]
jwe
parents: 162
diff changeset
313 error ("must all have the same number of elements");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
315 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
316
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
317 bounds.resize (lb_len);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
318 bounds.set_lower_bounds (lb);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
319 bounds.set_upper_bounds (ub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
320 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
321
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
322 double objf;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
323 ColumnVector lambda;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
324 int inform;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
326 if (nargin == 3)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
327 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
328 // 1. npsol (x, phi)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
329
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330 NPSOL nlp (x, func);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
331 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
332 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
333
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
334 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
335 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
336
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
337 if (nargin == 5)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
338 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
339 // 2. npsol (x, phi, lb, ub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
340
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
341 NPSOL nlp (x, func, bounds);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
342 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
343 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
344
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
345 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
346 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
347
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
348 npsol_constraints = NULL_TREE;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
349 if (nargin == 6 || nargin == 8 || nargin == 9 || nargin == 11)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
350 npsol_constraints = is_valid_function (args[nargin-2], "npsol", 0);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
351
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
352 if (nargin == 8 || nargin == 6)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
353 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
354 if (npsol_constraints == NULL_TREE)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
355 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
356 ColumnVector lub = args[nargin-1].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
357 Matrix c = args[nargin-2].to_matrix ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
358 ColumnVector llb = args[nargin-3].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
359
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
360 if (llb.capacity () == 0 || lub.capacity () == 0)
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
361 {
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
362 error ("npsol: bounds for linear constraints must be vectors");
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
363 return retval;
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
364 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
365
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
366 if (! linear_constraints_ok (x, llb, c, lub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
367 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
368
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
369 LinConst linear_constraints (llb, c, lub);
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
370
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
371 if (nargin == 6)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
372 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
373 // 7. npsol (x, phi, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
374
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
375 NPSOL nlp (x, func, linear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
376 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
377 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
378 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
379 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
380 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
381 // 3. npsol (x, phi, lb, ub, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
382
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
383 NPSOL nlp (x, func, bounds, linear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
384 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
385 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
386 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
387 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
388 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
389 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
390 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
391 if (takes_correct_nargs (npsol_constraints, 2, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
392 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
393 ColumnVector nlub = args[nargin-1].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
394 ColumnVector nllb = args[nargin-3].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
395
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
396 NLFunc const_func (npsol_constraint_function);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
397
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
398 if (! nonlinear_constraints_ok
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
399 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
400 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
401
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
402 NLConst nonlinear_constraints (nllb, const_func, nlub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
403
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
404 if (nargin == 6)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
405 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
406 // 8. npsol (x, phi, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
408 NPSOL nlp (x, func, nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
409 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
410 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
411 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
412 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
413 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
414 // 5. npsol (x, phi, lb, ub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
416 NPSOL nlp (x, func, bounds, nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
417 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
418 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
419 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
420 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
421 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
422 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
423 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
424
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425 if (nargin == 9 || nargin == 11)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
426 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
427 if (npsol_constraints == NULL_TREE)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429 // Produce error message.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430 is_valid_function (args[nargin-2], "npsol", 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
431 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
432 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
433 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
434 if (takes_correct_nargs (npsol_constraints, 2, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
435 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
436 ColumnVector nlub = args[nargin-1].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
437 ColumnVector nllb = args[nargin-3].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
438
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
439 NLFunc const_func (npsol_constraint_function);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
440
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
441 if (! nonlinear_constraints_ok
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
442 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
443 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
444
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
445 NLConst nonlinear_constraints (nllb, const_func, nlub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
446
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
447 ColumnVector lub = args[nargin-4].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
448 Matrix c = args[nargin-5].to_matrix ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
449 ColumnVector llb = args[nargin-6].to_vector ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
450
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
451 if (llb.capacity () == 0 || lub.capacity () == 0)
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
452 {
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
453 error ("npsol: bounds for linear constraints must be vectors");
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
454 return retval;
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
455 }
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
456
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
457 if (! linear_constraints_ok (x, llb, c, lub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
458 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
459
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
460 LinConst linear_constraints (llb, c, lub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
461
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
462 if (nargin == 9)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
463 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
464 // 6. npsol (x, phi, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
465
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
466 NPSOL nlp (x, func, linear_constraints,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
467 nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
468 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
469 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
470 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
471 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
472 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
473 // 4. npsol (x, phi, lb, ub, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
474
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
475 NPSOL nlp (x, func, bounds, linear_constraints,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
476 nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
477 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
478 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
479 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
480 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
481 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
482 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
483 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
484
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
485 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
486
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
487 solved:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
488
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
489 retval = new tree_constant [nargout+1];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
490 retval[0] = tree_constant (soln, 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
491 if (nargout > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
492 retval[1] = tree_constant (objf);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
493 if (nargout > 2)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
494 retval[2] = tree_constant ((double) inform);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
495 if (nargout > 3)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
496 retval[3] = tree_constant (lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
497
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
498 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
499 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
500
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
501 typedef void (NPSOL_options::*d_set_opt_mf) (double);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
502 typedef void (NPSOL_options::*i_set_opt_mf) (int);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
503 typedef double (NPSOL_options::*d_get_opt_mf) (void);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
504 typedef int (NPSOL_options::*i_get_opt_mf) (void);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
505
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
506 #define MAX_TOKENS 5
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
507
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
508 struct NPSOL_OPTIONS
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
509 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
510 char *keyword;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
511 char *kw_tok[MAX_TOKENS + 1];
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
512 int min_len[MAX_TOKENS + 1];
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
513 int min_toks_to_match;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
514 d_set_opt_mf d_set_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
515 i_set_opt_mf i_set_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
516 d_get_opt_mf d_get_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
517 i_get_opt_mf i_get_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
518 };
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
519
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
520 static NPSOL_OPTIONS npsol_option_table[] =
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
521 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
522 { "central difference interval",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
523 { "central", "difference", "interval", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
524 { 2, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
525 NPSOL_options::set_central_difference_interval, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
526 NPSOL_options::central_difference_interval, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
527
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
528 { "crash tolerance",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
529 { "crash", "tolerance", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
530 { 2, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
531 NPSOL_options::set_crash_tolerance, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
532 NPSOL_options::crash_tolerance, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
533
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
534 { "derivative level",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
535 { "derivative", "level", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
536 { 1, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
537 NULL, NPSOL_options::set_derivative_level,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
538 NULL, NPSOL_options::derivative_level, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
539
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
540 { "difference interval",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
541 { "difference", "interval", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
542 { 3, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
543 NPSOL_options::set_difference_interval, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
544 NPSOL_options::difference_interval, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
545
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
546 { "function precision",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
547 { "function", "precision", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
548 { 2, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
549 NPSOL_options::set_function_precision, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
550 NPSOL_options::function_precision, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
551
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
552 { "infinite bound size",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
553 { "infinite", "bound", "size", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
554 { 1, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
555 NPSOL_options::set_infinite_bound, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
556 NPSOL_options::infinite_bound, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
557
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
558 { "infinite step size",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
559 { "infinite", "step", "size", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
560 { 1, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
561 NPSOL_options::set_infinite_step, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
562 NPSOL_options::infinite_step, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
563
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
564 { "linear feasibility tolerance",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
565 { "linear", "feasibility", "tolerance", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
566 { 5, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
567 NPSOL_options::set_linear_feasibility_tolerance, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
568 NPSOL_options::linear_feasibility_tolerance, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
569
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
570 { "linesearch tolerance",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
571 { "linesearch", "tolerance", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
572 { 5, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
573 NPSOL_options::set_linesearch_tolerance, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
574 NPSOL_options::linesearch_tolerance, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
575
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
576 { "major iteration limit",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
577 { "major", "iteration", "limit", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
578 { 2, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
579 NULL, NPSOL_options::set_major_iteration_limit,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
580 NULL, NPSOL_options::major_iteration_limit, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
581
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
582 { "minor iteration limit",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
583 { "minor", "iteration", "limit", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
584 { 2, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
585 NULL, NPSOL_options::set_minor_iteration_limit,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
586 NULL, NPSOL_options::minor_iteration_limit, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
587
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
588 { "major print level",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
589 { "major", "print", "level", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
590 { 2, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
591 NULL, NPSOL_options::set_major_print_level,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
592 NULL, NPSOL_options::major_print_level, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
593
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
594 { "minor print level",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
595 { "minor", "print", "level", NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
596 { 2, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
597 NULL, NPSOL_options::set_minor_print_level,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
598 NULL, NPSOL_options::minor_print_level, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
599
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
600 { "nonlinear feasibility tolerance",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
601 { "nonlinear", "feasibility", "tolerance", NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
602 { 1, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
603 NPSOL_options::set_nonlinear_feasibility_tolerance, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
604 NPSOL_options::nonlinear_feasibility_tolerance, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
605
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
606 { "optimality tolerance",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
607 { "optimality", "tolerance", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
608 { 1, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
609 NPSOL_options::set_optimality_tolerance, NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
610 NPSOL_options::optimality_tolerance, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
611
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
612 { "start objective check at variable",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
613 { "start", "objective", "check", "at", "variable", NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
614 { 3, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
615 NULL, NPSOL_options::set_start_objective_check,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
616 NULL, NPSOL_options::start_objective_check, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
617
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
618 { "start constraint check at variable",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
619 { "start", "constraint", "check", "at", "variable", NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
620 { 3, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
621 NULL, NPSOL_options::set_start_constraint_check,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
622 NULL, NPSOL_options::start_constraint_check, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
623
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
624 { "stop objective check at variable",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
625 { "stop", "objective", "check", "at", "variable", NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
626 { 3, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
627 NULL, NPSOL_options::set_stop_objective_check,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
628 NULL, NPSOL_options::stop_objective_check, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
629
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
630 { "stop constraint check at variable",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
631 { "stop", "constraint", "check", "at", "variable", NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
632 { 3, 1, 0, 0, 0, 0, }, 2,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
633 NULL, NPSOL_options::set_stop_constraint_check,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
634 NULL, NPSOL_options::stop_constraint_check, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
635
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
636 { "verify level",
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
637 { "verify", "level", NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
638 { 1, 0, 0, 0, 0, 0, }, 1,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
639 NULL, NPSOL_options::set_verify_level,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
640 NULL, NPSOL_options::verify_level, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
641
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
642 { NULL,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
643 { NULL, NULL, NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
644 { 0, 0, 0, 0, 0, 0, }, 0,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
645 NULL, NULL, NULL, NULL, },
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
646 };
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
647
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
648 static void
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
649 print_npsol_option_list (void)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
650 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
651 ostrstream output_buf;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
652
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
653 print_usage ("npsol_options", 1);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
654
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
655 output_buf << "\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
656 << "Options for npsol include:\n\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
657 << " keyword value\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
658 << " ------- -----\n\n";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
659
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
660 NPSOL_OPTIONS *list = npsol_option_table;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
661
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
662 char *keyword;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
663 while ((keyword = list->keyword) != (char *) NULL)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
664 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
665 output_buf.form (" %-40s ", keyword);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
666 if (list->d_get_fcn)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
667 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
668 double val = (npsol_opts.*list->d_get_fcn) ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
669 if (val < 0.0)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
670 output_buf << "computed automatically";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
671 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
672 output_buf << val;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
673 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
674 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
675 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
676 int val = (npsol_opts.*list->i_get_fcn) ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
677 if (val < 0)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
678 output_buf << "depends on problem size";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
679 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
680 output_buf << val;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
681 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
682 output_buf << "\n";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
683 list++;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
684 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
685
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
686 output_buf << "\n" << ends;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
687 maybe_page_output (output_buf);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
688 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
689
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
690 static void
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
691 do_npsol_option (char *keyword, double val)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
692 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
693 NPSOL_OPTIONS *list = npsol_option_table;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
694
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
695 while (list->keyword != (char *) NULL)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
696 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
697 if (keyword_almost_match (list->kw_tok, list->min_len, keyword,
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
698 list->min_toks_to_match, MAX_TOKENS))
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
699 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
700 if (list->d_set_fcn)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
701 (npsol_opts.*list->d_set_fcn) (val);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
702 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
703 (npsol_opts.*list->i_set_fcn) (NINT (val));
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
704
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
705 return;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
706 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
707 list++;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
708 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
709
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
710 warning ("npsol_options: no match for `%s'", keyword);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
711 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
712
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
713 tree_constant *
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
714 npsol_options (const tree_constant *args, int nargin, int nargout)
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
715 {
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
716 tree_constant *retval = NULL_TREE_CONST;
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
717
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
718 if (nargin == 1)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
719 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
720 print_npsol_option_list ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
721 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
722 else if (nargin == 3)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
723 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
724 if (args[1].is_string_type ())
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
725 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
726 char *keyword = args[1].string_value ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
727 double val = args[2].double_value ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
728 do_npsol_option (keyword, val);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
729 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
730 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
731 print_usage ("npsol_options");
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
732 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
733 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
734 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
735 print_usage ("npsol_options");
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
736 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
737
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
738 return retval;
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
739 }
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
740
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
741 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
742
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
743 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
744 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
745 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
746 ;;; page-delimiter: "^/\\*" ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
747 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
748 */