1014
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
245
|
2 # |
|
3 # This file is part of Octave. |
|
4 # |
|
5 # Octave is free software; you can redistribute it and/or modify it |
|
6 # under the terms of the GNU General Public License as published by the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU General Public License |
|
16 # along with Octave; see the file COPYING. If not, write to the Free |
1315
|
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
245
|
18 |
4
|
19 function perror (name, err) |
|
20 |
|
21 # usage: perror (name, err) |
|
22 # |
|
23 # Print an error message for error number `err' from function "name". |
|
24 # |
|
25 # Messages correspond to the following subroutine versions: |
|
26 # |
|
27 # npsol : 4.0 |
|
28 # qpsol : 3.2 |
|
29 |
|
30 if (nargin != 2) |
904
|
31 usage ("perror (name, err)"); |
4
|
32 endif |
|
33 |
|
34 if (! isstr (name)) |
|
35 error ("perror: first argument must be a string"); |
|
36 endif |
|
37 |
|
38 if (! is_scalar (err)) |
|
39 error ("perror: second argument must be a scalar"); |
|
40 endif |
|
41 |
|
42 if (strcmp (name, "fsolve")) |
|
43 |
252
|
44 if (err == -2) |
4
|
45 printf ("input error\n"); |
252
|
46 elseif (err == -1) |
|
47 printf ("error encountered in user-supplied function\n"); |
107
|
48 elseif (err == 1) |
4
|
49 printf ("solution converged to requested tolerance\n"); |
107
|
50 elseif (err == 4) |
4
|
51 printf ("iteration limit exceeded\n"); |
107
|
52 elseif (err == 3) |
4
|
53 printf ("iteration is not making good progress\n"); |
|
54 else |
|
55 error ("perror: unrecognized error code for fsolve"); |
|
56 endif |
|
57 |
|
58 elseif (strcmp (name, "npsol")) |
|
59 |
|
60 if (err == 0) |
|
61 printf ("optimal solution found\n"); |
|
62 elseif (err == 1) |
|
63 printf ("weak local solution found\n"); |
|
64 elseif (err == 2) |
|
65 printf ("no feasible point for linear constraints and bounds\n"); |
|
66 elseif (err == 3) |
|
67 printf ("no feasible point found for nonlinear constraints\n"); |
|
68 elseif (err == 4) |
|
69 printf ("iteration limit reached\n"); |
|
70 elseif (err == 6) |
|
71 printf ("current point cannot be improved upon\n"); |
|
72 elseif (err == 7) |
|
73 printf ("user-supplied derivatives appear to be incorrect\n"); |
|
74 elseif (err == 9) |
|
75 printf ("internal error: invalid input parameter\n"); |
|
76 else |
|
77 error ("perror: unrecognized error code for npsol"); |
|
78 endif |
|
79 |
|
80 elseif (strcmp (name, "qpsol")) |
|
81 |
|
82 if (err == 0) |
|
83 printf ("optimal solution found\n"); |
|
84 elseif (err == 1) |
|
85 printf ("weak local solution found\n"); |
|
86 elseif (err == 2) |
|
87 printf ("solution appears to be unbounded\n"); |
|
88 elseif (err == 3) |
|
89 printf ("solution appears optimal, but optimality can't be verified\n"); |
|
90 elseif (err == 4) |
|
91 printf ("iterates of the QP phase appear to be cycling\n"); |
|
92 elseif (err == 5) |
|
93 printf ("iteration limit reached during QP phase\n"); |
|
94 elseif (err == 6) |
|
95 printf ("no feasible point found during LP phase\n"); |
|
96 elseif (err == 7) |
|
97 printf ("iterates of the LP phase appear to be cycling\n"); |
|
98 elseif (err == 8) |
|
99 printf ("iteration limit reached during LP phase\n"); |
|
100 elseif (err == 9) |
|
101 printf ("internal error: invalid input parameter\n"); |
|
102 else |
|
103 error ("perror: unrecognized error code for qpsol"); |
|
104 endif |
|
105 |
|
106 else |
|
107 |
|
108 error ("perror: unrecognized function name"); |
|
109 |
|
110 endif |
|
111 |
|
112 endfunction |