Loading...
Searching...
No Matches
special_values.m
1function special_values(varargin)
2
3 % check workspace info from arguments
4 if nargin > 0
5 wsInfo = gams.control.WorkspaceInfo();
6 wsInfo.systemDirectory = varargin{1};
7 ws = gams.control.Workspace(wsInfo);
8 else
9 ws = gams.control.Workspace();
10 end
11
12 model = {
13 'Scalar GUndef '
14 ' GNA / NA / '
15 ' GPInf / +Inf / '
16 ' GMInf / -Inf / '
17 ' GEps / eps / '
18 ' matlabUndef '
19 ' matlabNA '
20 ' matlabPInf '
21 ' matlabMInf '
22 ' matlabEps ; '
23 ' '
24 '$onUndf '
25 '$gdxIn %gdxincname% '
26 '$load matlabUndef matlabNA matlabPInf matlabMInf matlabEps '
27 '$gdxIn '
28 ' '
29 'GUndef = 1/0; '
30 'ExecError = 0; '
31 ' '
32 'abort$(GUndef <> matlabUndef) ''matlabUndef not as expected'', GUndef, matlabUndef;'
33 'abort$(GNA <> matlabNA ) ''matlabNA not as expected'', GNA, matlabNA; '
34 'abort$(GPInf <> matlabPInf ) ''matlabPInf not as expected'', GPInf, matlabPInf; '
35 'abort$(GMInf <> matlabMInf ) ''matlabMInf not as expected'', GMInf, matlabMInf; '
36 'abort$(GEps <> matlabEps ) ''matlabEps not as expected'', GEps, matlabEps '};
37 model = sprintf('%s\n', model{:});
38
39 dbIn = ws.addDatabase('myDB');
40 rec = dbIn.addParameter('matlabUndef', 0).addRecord();
41 rec.value = 1.0E300;
42 rec = dbIn.addParameter('matlabNA', 0).addRecord();
43 rec.value = NaN;
44 rec = dbIn.addParameter('matlabPInf', 0).addRecord();
45 rec.value = Inf;
46 rec = dbIn.addParameter('matlabMInf', 0).addRecord();
47 rec.value = -Inf;
48 rec = dbIn.addParameter('matlabEps', 0).addRecord();
49 rec.value = 4.94066E-324;
50
51 gj = ws.addJobFromString(model);
52 opt = ws.addOptions();
53 opt.defines('gdxincname', dbIn.name);
54 gj.run(opt, dbIn);
55
56 dbOut = gj.outDB;
57 GUndef = dbOut.getParameter('GUndef').record.value;
58 if GUndef ~= 1.0E300
59 error('GUndef not as expected: %f', GUndef);
60 end
61 GNA = dbOut.getParameter('GNA').record.value;
62 if ~isnan(GNA)
63 error('GNA not as expected: %f', GNA);
64 end
65 GPInf = dbOut.getParameter('GPInf').record.value;
66 if ~isinf(GPInf)
67 error('GPInf not as expected: %f', GPInf);
68 end
69 GMInf = dbOut.getParameter('GMInf').record.value;
70 if ~isinf(GMInf) && GMInf < 0
71 error('GMInf not as expected: %f', GMInf);
72 end
73 GEps = dbOut.getParameter('GEps').record.value;
74 if GEps ~= 4.94066E-324
75 error('GEps not as expected: %f', GEps);
76 end
77
78 % clear option and database
79 opt.dispose();
80 gj.outDB.dispose();
81
82 % remove working directory
83 rmdir(ws.workingDirectory, 's');
84
85end