annotate src/npsol.cc @ 1192:b6360f2d4fa6

[project @ 1995-03-30 21:38:35 by jwe]
author jwe
date Thu, 30 Mar 1995 21:38:35 +0000
parents 75fc98220389
children 611d403c7f3d
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
1009
dfe01093f657 [project @ 1995-01-04 04:05:12 by jwe]
jwe
parents: 945
diff changeset
4 Copyright (C) 1993, 1994, 1995 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
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1086
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
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
28 #include <strstream.h>
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
29
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30 #include "NPSOL.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
31
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
32 #include "tree-const.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
33 #include "variables.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
34 #include "gripes.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
35 #include "error.h"
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
36 #include "pager.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37 #include "utils.h"
544
20fbad23ae51 [project @ 1994-07-22 05:04:44 by jwe]
jwe
parents: 540
diff changeset
38 #include "help.h"
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
39 #include "defun-dld.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
40
646
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
41 #ifndef NPSOL_MISSING
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
42
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
43 // Global pointers for user defined functions required by npsol.
488
4481fdfb01b4 [project @ 1994-07-06 14:31:07 by jwe]
jwe
parents: 296
diff changeset
44 static tree_fvc *npsol_objective;
4481fdfb01b4 [project @ 1994-07-06 14:31:07 by jwe]
jwe
parents: 296
diff changeset
45 static tree_fvc *npsol_constraints;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
47 static NPSOL_options npsol_opts;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
48
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
49 double
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
50 npsol_objective_function (const ColumnVector& x)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
52 int n = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 tree_constant decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55 if (n > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57 Matrix m (n, 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
58 for (int i = 0; i < n; i++)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59 m (i, 0) = x.elem (i);
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
60 decision_vars = m;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
61 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
62 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
63 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
64 double d = x.elem (0);
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
65 decision_vars = d;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
66 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
67
565
b04c0d02f2de [project @ 1994-07-26 01:03:20 by jwe]
jwe
parents: 544
diff changeset
68 Octave_object args;
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
69 args(0) = decision_vars;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
71 static double retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
72 retval = 0.0;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
73
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74 tree_constant objective_value;
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
75 if (npsol_objective)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
76 {
506
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
77 Octave_object tmp = npsol_objective->eval (0, 1, args);
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
78
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
79 if (error_state)
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
80 {
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
81 error ("npsol: error evaluating objective function");
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
82 npsol_objective_error = 1; // XXX FIXME XXX
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
83 return retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
84 }
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
85
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
86 if (tmp.length () > 0 && tmp(0).is_defined ())
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
87 objective_value = tmp(0);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
88 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
89 {
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
90 error ("npsol: error evaluating objective function");
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
91 npsol_objective_error = 1; // XXX FIXME XXX
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
92 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
93 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
94 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
95
620
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
96 if (objective_value.is_real_matrix ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
97 {
620
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
98 Matrix m = objective_value.matrix_value ();
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
99 if (m.rows () == 1 && m.columns () == 1)
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
100 retval = m.elem (0, 0);
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
101 else
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
102 {
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
103 gripe_user_returned_invalid ("npsol_objective");
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
104 npsol_objective_error = 1; // XXX FIXME XXX
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
105 }
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
106 }
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
107 else if (objective_value.is_real_scalar ())
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
108 {
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
109 retval = objective_value.double_value ();
620
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
110 }
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
111 else
8e4e7e5f307e [project @ 1994-08-16 04:36:32 by jwe]
jwe
parents: 610
diff changeset
112 {
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
113 gripe_user_returned_invalid ("npsol_objective");
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
114 npsol_objective_error = 1; // XXX FIXME XXX
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
115 }
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 return retval;
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
120 ColumnVector
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
121 npsol_constraint_function (const ColumnVector& x)
1
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 ColumnVector retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 int n = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127 tree_constant decision_vars;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
128 if (n > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
129 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
130 Matrix m (n, 1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
131 for (int i = 0; i < n; i++)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
132 m (i, 0) = x.elem (i);
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
133 decision_vars = m;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
134 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
135 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
136 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
137 double d = x.elem (0);
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
138 decision_vars = d;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
139 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
140
565
b04c0d02f2de [project @ 1994-07-26 01:03:20 by jwe]
jwe
parents: 544
diff changeset
141 Octave_object args;
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
142 args(0) = decision_vars;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
143
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
144 if (npsol_constraints)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
145 {
506
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
146 Octave_object tmp = npsol_constraints->eval (0, 1, args);
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
147
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
148 if (error_state)
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
149 {
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
150 error ("npsol: error evaluating constraints");
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
151 return retval;
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
152 }
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
153
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
154 if (tmp.length () > 0 && tmp(0).is_defined ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
155 {
628
aecbe369233b [project @ 1994-08-19 13:27:51 by jwe]
jwe
parents: 620
diff changeset
156 retval = tmp(0).vector_value ();
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
157
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
158 if (error_state || retval.length () <= 0)
255
98246fedc941 [project @ 1993-12-08 22:55:41 by jwe]
jwe
parents: 240
diff changeset
159 error ("npsol: error evaluating constraints");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
160 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
161 else
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
162 error ("npsol: error evaluating constraints");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
163 }
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 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
166 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
167
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
168 int
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
169 linear_constraints_ok (const ColumnVector& x, const ColumnVector& llb,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
170 const Matrix& c, const ColumnVector& lub,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
171 char *warn_for, int warn)
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 int x_len = x.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
174 int llb_len = llb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
175 int lub_len = lub.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
176 int c_rows = c.rows ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
177 int c_cols = c.columns ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
178
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
179 int ok = 1;
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
180 if (warn)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
181 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
182 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
183 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
184 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
185 error ("%s: linear constraints must have nonzero dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
186 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
187 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
188 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
189 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
190 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
191 error ("%s: linear constraints have inconsistent dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
192 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
193 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
194 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
195
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
196 return ok;
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 int
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
200 nonlinear_constraints_ok (const ColumnVector& x, const ColumnVector& nllb,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
201 nonlinear_fcn g, const ColumnVector& nlub,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
202 char *warn_for, int warn)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
203 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
204 int nllb_len = nllb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
205 int nlub_len = nlub.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
206 ColumnVector c = (*g) (x);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
207 int c_len = c.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
208
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
209 int ok = 1;
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
210 if (warn)
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
211 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
212 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
213 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
214 ok = 0;
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
215 error ("%s: nonlinear constraints have nonzero dimensions",
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
216 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
217 }
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
218 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
219 {
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
220 ok = 0;
162
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
221 error ("%s: nonlinear constraints have inconsistent dimensions",
d1c5e5edbf1e [project @ 1993-10-18 19:26:01 by jwe]
jwe
parents: 158
diff changeset
222 warn_for);
132
0869dc33276c [project @ 1993-09-28 21:06:42 by jwe]
jwe
parents: 7
diff changeset
223 }
135
7aea883afd29 [project @ 1993-09-29 16:15:12 by jwe]
jwe
parents: 132
diff changeset
224 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
225 return ok;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
226 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
227
646
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
228 #endif
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
229
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
230 #if defined (NPSOL_MISSING)
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
231 DEFUN_DLD_BUILTIN ("npsol", Fnpsol, Snpsol, 10, 4,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
232 "This function requires NPSOL, which is not freely\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
233 redistributable. For more information, read the file\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
234 libcruft/npsol/README.MISSING in the source distribution.")
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
235 #else
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
236 DEFUN_DLD_BUILTIN ("npsol", Fnpsol, Snpsol, 10, 4,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
237 "[X, OBJ, INFO, LAMBDA] = npsol (X, PHI [, LB, UB] [, LB, A, UB] [, LB, G, UB])\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
238 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
239 Groups of arguments surrounded in `[]' are optional, but\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
240 must appear in the same relative order shown above.\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
241 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
242 The second argument is a string containing the name of the objective\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
243 function to call. The objective function must be of the form\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
244 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
245 y = phi (x)\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
246 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
247 where x is a vector and y is a scalar.\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
248 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
249 The argument G is a string containing the name of the function that
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
250 defines the nonlinear constraints. It must be of the form\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
251 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
252 y = g (x)\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
253 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
254 where x is a vector and y is a vector.")
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
255 #endif
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
256 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
257 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
258
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
259 Handle all of the following:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
260
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
261 1. npsol (x, phi)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
262 2. npsol (x, phi, lb, ub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
263 3. npsol (x, phi, lb, ub, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
264 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
265 5. npsol (x, phi, lb, ub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
266 6. npsol (x, phi, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
267 7. npsol (x, phi, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268 8. npsol (x, phi, nllb, g, nlub)
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 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
272 Octave_object retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
273
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
274 #if defined (NPSOL_MISSING)
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
275
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
276 // Force a bad value of inform, and empty matrices for x, phi, and lambda.
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
277
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
278 retval.resize (4, Matrix ());
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
279
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
280 retval(2) = -1.0;
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
281
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
282 print_usage ("npsol");
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
283
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
284 #else
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
285
506
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
286 int nargin = args.length ();
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
287
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
288 if (nargin < 2 || nargin == 3 || nargin == 6 || nargin == 9
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
289 || nargin > 10 || nargout > 4)
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
290 {
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
291 print_usage ("npsol");
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
292 return retval;
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
293 }
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
294
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
295 ColumnVector x = args(0).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
296
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
297 if (error_state || x.capacity () == 0)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
298 {
158
76926a2d39a6 [project @ 1993-10-13 20:48:27 by jwe]
jwe
parents: 135
diff changeset
299 error ("npsol: expecting vector as first argument");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
300 return retval;
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
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
303 npsol_objective = is_valid_function (args(1), "npsol", 1);
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
304 if (! npsol_objective
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
305 || takes_correct_nargs (npsol_objective, 1, "npsol", 1) != 1)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
306 return retval;
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 Objective func (npsol_objective_function);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
310 ColumnVector soln;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
311
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
312 Bounds bounds;
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
313 if (nargin == 4 || nargin == 7 || nargin == 10)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 {
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
315 ColumnVector lb = args(2).vector_value ();
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
316 ColumnVector ub = args(3).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
317
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
318 int lb_len = lb.capacity ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
319 int ub_len = ub.capacity ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
320
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
321 if (error_state || lb_len != ub_len || lb_len != x.capacity ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
322 {
214
1468a5e6a466 [project @ 1993-11-13 04:04:32 by jwe]
jwe
parents: 162
diff changeset
323 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
324 error ("must all have the same number of elements");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
326 }
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 bounds.resize (lb_len);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
329 bounds.set_lower_bounds (lb);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330 bounds.set_upper_bounds (ub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
331 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
332
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
333 double objf;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
334 ColumnVector lambda;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
335 int inform;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
336
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
337 if (nargin == 2)
1
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 // 1. npsol (x, phi)
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);
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
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
348 if (nargin == 4)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
349 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
350 // 2. npsol (x, phi, lb, ub)
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 NPSOL nlp (x, func, bounds);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
353 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
354 soln = nlp.minimize (objf, inform, lambda);
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 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
357 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
358
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
359 npsol_constraints = 0;
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
360 if (nargin == 5 || nargin == 7 || nargin == 8 || nargin == 10)
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
361 npsol_constraints = is_valid_function (args(nargin-2), "npsol", 0);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
362
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
363 if (nargin == 7 || nargin == 5)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
364 {
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
365 if (! npsol_constraints)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
366 {
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
367 ColumnVector lub = args(nargin-1).vector_value ();
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
368 ColumnVector llb = args(nargin-3).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
369
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
370 if (error_state || llb.capacity () == 0 || lub.capacity () == 0)
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
371 {
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
372 error ("npsol: bounds for linear constraints must be vectors");
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
373 return retval;
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
374 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
375
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
376 Matrix c = args(nargin-2).matrix_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
377
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
378 if (error_state)
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
379 {
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
380 error ("npsol: invalid linear constraint matrix");
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
381 return retval;
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
382 }
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
383
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
384 if (! linear_constraints_ok (x, llb, c, lub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
385 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
386
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
387 LinConst linear_constraints (llb, c, lub);
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
388
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
389 if (nargin == 5)
1
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 // 7. npsol (x, phi, llb, c, lub)
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 NPSOL nlp (x, func, linear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
394 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
395 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
396 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
397 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
398 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
399 // 3. npsol (x, phi, lb, ub, llb, c, lub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
400
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
401 NPSOL nlp (x, func, bounds, linear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
402 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
403 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
404 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
405 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
406 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
408 {
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
409 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1))
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
410 {
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
411 ColumnVector nlub = args(nargin-1).vector_value ();
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
412 ColumnVector nllb = args(nargin-3).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
413
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
414 if (error_state
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
415 || (! nonlinear_constraints_ok
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
416 (x, nllb, npsol_constraint_function, nlub, "npsol", 1)))
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
417 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
418
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
419 NLFunc const_func (npsol_constraint_function);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
420 NLConst nonlinear_constraints (nllb, const_func, nlub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
421
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
422 if (nargin == 5)
1
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 // 8. npsol (x, phi, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
426 NPSOL nlp (x, func, nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
427 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430 else
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 // 5. npsol (x, phi, lb, ub, nllb, g, nlub)
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 NPSOL nlp (x, func, bounds, nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
435 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
436 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
437 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
438 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
439 }
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 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
442
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
443 if (nargin == 8 || nargin == 10)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
444 {
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
445 if (! npsol_constraints)
1
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 // Produce error message.
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
448 is_valid_function (args(nargin-2), "npsol", 1);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
449 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
450 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
451 {
718
e81d3a66725e [project @ 1994-09-21 14:58:18 by jwe]
jwe
parents: 712
diff changeset
452 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1))
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
453 {
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
454 ColumnVector nlub = args(nargin-1).vector_value ();
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
455 ColumnVector nllb = args(nargin-3).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
456
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
457 if (error_state
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
458 || (! nonlinear_constraints_ok
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
459 (x, nllb, npsol_constraint_function, nlub, "npsol", 1)))
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
460 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
461
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
462 NLFunc const_func (npsol_constraint_function);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
463 NLConst nonlinear_constraints (nllb, const_func, nlub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
464
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
465 ColumnVector lub = args(nargin-4).vector_value ();
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
466 ColumnVector llb = args(nargin-6).vector_value ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
467
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
468 if (error_state || llb.capacity () == 0 || lub.capacity () == 0)
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
469 {
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
470 error ("npsol: bounds for linear constraints must be vectors");
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
471 return retval;
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
472 }
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
473
945
a1b0080599e5 [project @ 1994-11-21 21:56:42 by jwe]
jwe
parents: 718
diff changeset
474 Matrix c = args(nargin-5).matrix_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
475
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
476 if (error_state)
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
477 {
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
478 error ("npsol: invalid linear constraint matrix");
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
479 return retval;
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
480 }
215
cf3f13026ff6 [project @ 1993-11-13 08:41:22 by jwe]
jwe
parents: 214
diff changeset
481
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
482 if (! linear_constraints_ok (x, llb, c, lub, "npsol", 1))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
483 return retval;
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 LinConst linear_constraints (llb, c, lub);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
486
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
487 if (nargin == 8)
1
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 // 6. npsol (x, phi, llb, c, lub, nllb, g, nlub)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
490
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
491 NPSOL nlp (x, func, linear_constraints,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
492 nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
493 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
494 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
495 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
496 else
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 // 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
499
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
500 NPSOL nlp (x, func, bounds, linear_constraints,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
501 nonlinear_constraints);
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
502 nlp.copy (npsol_opts);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
503 soln = nlp.minimize (objf, inform, lambda);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
504 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
505 goto solved;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
506 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
507 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
508 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
509
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
510 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
511
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
512 solved:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
513
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
514 retval.resize (nargout ? nargout : 1);
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
515 retval(0) = soln, 1;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
516 if (nargout > 1)
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
517 retval(1) = objf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
518 if (nargout > 2)
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
519 retval(2) = (double) inform;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
520 if (nargout > 3)
516
309fc59f66ee [project @ 1994-07-13 02:31:31 by jwe]
jwe
parents: 506
diff changeset
521 retval(3) = lambda;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
522
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
523 #endif
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
524
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
525 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
526 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
527
646
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
528 #ifndef NPSOL_MISSING
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
529
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
530 typedef void (NPSOL_options::*d_set_opt_mf) (double);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
531 typedef void (NPSOL_options::*i_set_opt_mf) (int);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
532 typedef double (NPSOL_options::*d_get_opt_mf) (void);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
533 typedef int (NPSOL_options::*i_get_opt_mf) (void);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
534
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
535 #define MAX_TOKENS 5
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
536
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
537 struct NPSOL_OPTIONS
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
538 {
540
c07674bbc3b1 [project @ 1994-07-21 23:59:00 by jwe]
jwe
parents: 519
diff changeset
539 const char *keyword;
c07674bbc3b1 [project @ 1994-07-21 23:59:00 by jwe]
jwe
parents: 519
diff changeset
540 const char *kw_tok[MAX_TOKENS + 1];
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
541 int min_len[MAX_TOKENS + 1];
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
542 int min_toks_to_match;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
543 d_set_opt_mf d_set_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
544 i_set_opt_mf i_set_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
545 d_get_opt_mf d_get_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
546 i_get_opt_mf i_get_fcn;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
547 };
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
548
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
549 static NPSOL_OPTIONS npsol_option_table [] =
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
550 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
551 { "central difference interval",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
552 { "central", "difference", "interval", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
553 { 2, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
554 NPSOL_options::set_central_difference_interval, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
555 NPSOL_options::central_difference_interval, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
556
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
557 { "crash tolerance",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
558 { "crash", "tolerance", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
559 { 2, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
560 NPSOL_options::set_crash_tolerance, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
561 NPSOL_options::crash_tolerance, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
562
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
563 { "derivative level",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
564 { "derivative", "level", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
565 { 1, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
566 0, NPSOL_options::set_derivative_level,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
567 0, NPSOL_options::derivative_level, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
568
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
569 { "difference interval",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
570 { "difference", "interval", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
571 { 3, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
572 NPSOL_options::set_difference_interval, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
573 NPSOL_options::difference_interval, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
574
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
575 { "function precision",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
576 { "function", "precision", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
577 { 2, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
578 NPSOL_options::set_function_precision, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
579 NPSOL_options::function_precision, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
580
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
581 { "infinite bound size",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
582 { "infinite", "bound", "size", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
583 { 1, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
584 NPSOL_options::set_infinite_bound, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
585 NPSOL_options::infinite_bound, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
586
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
587 { "infinite step size",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
588 { "infinite", "step", "size", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
589 { 1, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
590 NPSOL_options::set_infinite_step, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
591 NPSOL_options::infinite_step, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
592
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
593 { "linear feasibility tolerance",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
594 { "linear", "feasibility", "tolerance", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
595 { 5, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
596 NPSOL_options::set_linear_feasibility_tolerance, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
597 NPSOL_options::linear_feasibility_tolerance, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
598
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
599 { "linesearch tolerance",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
600 { "linesearch", "tolerance", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
601 { 5, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
602 NPSOL_options::set_linesearch_tolerance, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
603 NPSOL_options::linesearch_tolerance, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
604
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
605 { "major iteration limit",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
606 { "major", "iteration", "limit", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
607 { 2, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
608 0, NPSOL_options::set_major_iteration_limit,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
609 0, NPSOL_options::major_iteration_limit, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
610
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
611 { "minor iteration limit",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
612 { "minor", "iteration", "limit", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
613 { 2, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
614 0, NPSOL_options::set_minor_iteration_limit,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
615 0, NPSOL_options::minor_iteration_limit, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
616
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
617 { "major print level",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
618 { "major", "print", "level", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
619 { 2, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
620 0, NPSOL_options::set_major_print_level,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
621 0, NPSOL_options::major_print_level, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
622
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
623 { "minor print level",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
624 { "minor", "print", "level", 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
625 { 2, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
626 0, NPSOL_options::set_minor_print_level,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
627 0, NPSOL_options::minor_print_level, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
628
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
629 { "nonlinear feasibility tolerance",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
630 { "nonlinear", "feasibility", "tolerance", 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
631 { 1, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
632 NPSOL_options::set_nonlinear_feasibility_tolerance, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
633 NPSOL_options::nonlinear_feasibility_tolerance, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
634
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
635 { "optimality tolerance",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
636 { "optimality", "tolerance", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
637 { 1, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
638 NPSOL_options::set_optimality_tolerance, 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
639 NPSOL_options::optimality_tolerance, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
640
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
641 { "start objective check at variable",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
642 { "start", "objective", "check", "at", "variable", 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
643 { 3, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
644 0, NPSOL_options::set_start_objective_check,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
645 0, NPSOL_options::start_objective_check, },
287
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 { "start constraint check at variable",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
648 { "start", "constraint", "check", "at", "variable", 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
649 { 3, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
650 0, NPSOL_options::set_start_constraint_check,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
651 0, NPSOL_options::start_constraint_check, },
287
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 { "stop objective check at variable",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
654 { "stop", "objective", "check", "at", "variable", 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
655 { 3, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
656 0, NPSOL_options::set_stop_objective_check,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
657 0, NPSOL_options::stop_objective_check, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
658
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
659 { "stop constraint check at variable",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
660 { "stop", "constraint", "check", "at", "variable", 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
661 { 3, 1, 0, 0, 0, 0, }, 2,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
662 0, NPSOL_options::set_stop_constraint_check,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
663 0, NPSOL_options::stop_constraint_check, },
287
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 { "verify level",
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
666 { "verify", "level", 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
667 { 1, 0, 0, 0, 0, 0, }, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
668 0, NPSOL_options::set_verify_level,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
669 0, NPSOL_options::verify_level, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
670
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
671 { 0,
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
672 { 0, 0, 0, 0, 0, 0, },
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
673 { 0, 0, 0, 0, 0, 0, }, 0,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
674 0, 0, 0, 0, },
287
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
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
677 static void
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
678 print_npsol_option_list (void)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
679 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
680 ostrstream output_buf;
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 print_usage ("npsol_options", 1);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
683
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
684 output_buf << "\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
685 << "Options for npsol include:\n\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
686 << " keyword value\n"
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
687 << " ------- -----\n\n";
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 NPSOL_OPTIONS *list = npsol_option_table;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
690
540
c07674bbc3b1 [project @ 1994-07-21 23:59:00 by jwe]
jwe
parents: 519
diff changeset
691 const char *keyword;
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
692 while ((keyword = list->keyword) != 0)
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
693 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
694 output_buf.form (" %-40s ", keyword);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
695 if (list->d_get_fcn)
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 double val = (npsol_opts.*list->d_get_fcn) ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
698 if (val < 0.0)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
699 output_buf << "computed automatically";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
700 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
701 output_buf << val;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
702 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
703 else
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 int val = (npsol_opts.*list->i_get_fcn) ();
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
706 if (val < 0)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
707 output_buf << "depends on problem size";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
708 else
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
709 output_buf << val;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
710 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
711 output_buf << "\n";
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
712 list++;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
713 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
714
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
715 output_buf << "\n" << ends;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
716 maybe_page_output (output_buf);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
717 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
718
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
719 static void
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
720 do_npsol_option (char *keyword, double val)
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 NPSOL_OPTIONS *list = npsol_option_table;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
723
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
724 while (list->keyword != 0)
287
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 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
727 list->min_toks_to_match, MAX_TOKENS))
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
728 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
729 if (list->d_set_fcn)
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
730 (npsol_opts.*list->d_set_fcn) (val);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
731 else
1086
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
732 {
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
733 if (xisnan (val))
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
734 {
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
735 error ("npsol_options: %s: expecting integer, found NaN",
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
736 keyword);
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
737 }
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
738 else
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
739 (npsol_opts.*list->i_set_fcn) (NINT (val));
75fc98220389 [project @ 1995-01-31 04:17:15 by jwe]
jwe
parents: 1009
diff changeset
740 }
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
741 return;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
742 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
743 list++;
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
744 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
745
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
746 warning ("npsol_options: no match for `%s'", keyword);
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
747 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
748
646
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
749 #endif
209eafc06817 [project @ 1994-08-24 06:41:56 by jwe]
jwe
parents: 644
diff changeset
750
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
751 #if defined (NPSOL_MISSING)
701
0a81458ef677 [project @ 1994-09-15 02:23:24 by jwe]
jwe
parents: 646
diff changeset
752 DEFUN_DLD_BUILTIN ("npsol_options", Fnpsol_options, Snpsol_options, -1, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
753 "This function requires NPSOL, which is not freely\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
754 redistributable. For more information, read the file\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
755 libcruft/npsol/README.MISSING in the source distribution.")
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
756 #else
701
0a81458ef677 [project @ 1994-09-15 02:23:24 by jwe]
jwe
parents: 646
diff changeset
757 DEFUN_DLD_BUILTIN ("npsol_options", Fnpsol_options, Snpsol_options, -1, 1,
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
758 "npsol_options (KEYWORD, VALUE)\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
759 \n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
760 Set or show options for npsol. Keywords may be abbreviated\n\
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
761 to the shortest match.")
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
762 #endif
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
763 {
497
88614b380d6e [project @ 1994-07-08 02:00:57 by jwe]
jwe
parents: 488
diff changeset
764 Octave_object retval;
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
765
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
766 #if defined (NPSOL_MISSING)
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
767
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
768 print_usage ("npsol_options");
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
769
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
770 #else
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
771
506
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
772 int nargin = args.length ();
0f388340e607 [project @ 1994-07-09 06:10:34 by jwe]
jwe
parents: 497
diff changeset
773
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
774 if (nargin == 0)
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
775 {
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
776 print_npsol_option_list ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
777 return retval;
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
778 }
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
779 else if (nargin == 2)
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
780 {
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
781 char *keyword = args(0).string_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
782
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
783 if (! error_state)
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
784 {
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 701
diff changeset
785 double val = args(1).double_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
786
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
787 if (! error_state)
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
788 {
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
789 do_npsol_option (keyword, val);
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
790 return retval;
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
791 }
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
792 }
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
793 }
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
794
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 628
diff changeset
795 print_usage ("npsol_options");
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 272
diff changeset
796
519
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
797 #endif
b9284136189a [project @ 1994-07-19 14:40:20 by jwe]
jwe
parents: 516
diff changeset
798
272
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
799 return retval;
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
800 }
7ec58832918f [project @ 1994-01-06 18:54:08 by jwe]
jwe
parents: 260
diff changeset
801
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
802 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
803 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
804 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
805 ;;; page-delimiter: "^/\\*" ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
806 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
807 */