4
|
1 function perror (name, err) |
|
2 |
|
3 # usage: perror (name, err) |
|
4 # |
|
5 # Print an error message for error number `err' from function "name". |
|
6 # |
|
7 # Messages correspond to the following subroutine versions: |
|
8 # |
|
9 # npsol : 4.0 |
|
10 # qpsol : 3.2 |
|
11 |
|
12 if (nargin != 2) |
|
13 error ("usage: perror (name, err)"); |
|
14 endif |
|
15 |
|
16 if (! isstr (name)) |
|
17 error ("perror: first argument must be a string"); |
|
18 endif |
|
19 |
|
20 if (! is_scalar (err)) |
|
21 error ("perror: second argument must be a scalar"); |
|
22 endif |
|
23 |
|
24 if (strcmp (name, "fsolve")) |
|
25 |
|
26 if (info == -1) |
|
27 printf ("input error\n"); |
|
28 elseif (info == 1) |
|
29 printf ("solution converged to requested tolerance\n"); |
|
30 elseif (info == 4) |
|
31 printf ("iteration limit exceeded\n"); |
|
32 elseif (info == 3) |
|
33 printf ("iteration is not making good progress\n"); |
|
34 else |
|
35 error ("perror: unrecognized error code for fsolve"); |
|
36 endif |
|
37 |
|
38 elseif (strcmp (name, "npsol")) |
|
39 |
|
40 if (err == 0) |
|
41 printf ("optimal solution found\n"); |
|
42 elseif (err == 1) |
|
43 printf ("weak local solution found\n"); |
|
44 elseif (err == 2) |
|
45 printf ("no feasible point for linear constraints and bounds\n"); |
|
46 elseif (err == 3) |
|
47 printf ("no feasible point found for nonlinear constraints\n"); |
|
48 elseif (err == 4) |
|
49 printf ("iteration limit reached\n"); |
|
50 elseif (err == 6) |
|
51 printf ("current point cannot be improved upon\n"); |
|
52 elseif (err == 7) |
|
53 printf ("user-supplied derivatives appear to be incorrect\n"); |
|
54 elseif (err == 9) |
|
55 printf ("internal error: invalid input parameter\n"); |
|
56 else |
|
57 error ("perror: unrecognized error code for npsol"); |
|
58 endif |
|
59 |
|
60 elseif (strcmp (name, "qpsol")) |
|
61 |
|
62 if (err == 0) |
|
63 printf ("optimal solution found\n"); |
|
64 elseif (err == 1) |
|
65 printf ("weak local solution found\n"); |
|
66 elseif (err == 2) |
|
67 printf ("solution appears to be unbounded\n"); |
|
68 elseif (err == 3) |
|
69 printf ("solution appears optimal, but optimality can't be verified\n"); |
|
70 elseif (err == 4) |
|
71 printf ("iterates of the QP phase appear to be cycling\n"); |
|
72 elseif (err == 5) |
|
73 printf ("iteration limit reached during QP phase\n"); |
|
74 elseif (err == 6) |
|
75 printf ("no feasible point found during LP phase\n"); |
|
76 elseif (err == 7) |
|
77 printf ("iterates of the LP phase appear to be cycling\n"); |
|
78 elseif (err == 8) |
|
79 printf ("iteration limit reached during LP phase\n"); |
|
80 elseif (err == 9) |
|
81 printf ("internal error: invalid input parameter\n"); |
|
82 else |
|
83 error ("perror: unrecognized error code for qpsol"); |
|
84 endif |
|
85 |
|
86 else |
|
87 |
|
88 error ("perror: unrecognized function name"); |
|
89 |
|
90 endif |
|
91 |
|
92 endfunction |