Page 1 of 1

Solvers error when calling from MatLab

Posted: Sat Jun 23, 2018 2:17 am
by xtssss
I currently concur an issue when calling Gams from Matlab.
I solve a MINLP problem and write 'Option MINLP=COUENNE' in Gams.
It works fine when I directly ran the code in Gams, however, when I run the code from Matlab using 'system' function, there is always an error with error code $253, which said that
'Unknown algorithm:
The GAMS statement 'option subsystem;' will list the installed subsystems in the GAMS listing file.'

I couldn't find the listed subsystems in the file neither debug the error. It would be a great help if someone can give me a hint.

Thanks!

Re: Solvers error when calling from MatLab

Posted: Mon Jun 25, 2018 6:15 am
by Renger
Hi
The error message has a typo, therefore the option doesn't work.
It should be plural (as you can see if you try it out in the error message you get)

option subsystems;

Hope this helps
Renger

Re: Solvers error when calling from MatLab

Posted: Mon Jun 25, 2018 9:35 am
by Fred
Hi xtssss,

Actually, the error message should read

Unknown algorithm
The GAMS statement 'option subsystems;' will list
the installed subsystems in the GAMS listing file.

Maybe you introduced the typo yourself?
Is there a chance that from Matlab you are using a GAMS version older than 23.1.1? In this version COUENNE was introduced.

Best,
Fred

Re: Solvers error when calling from MatLab

Posted: Tue Jul 03, 2018 7:18 pm
by xtssss
Yes, it is plural.
Renger wrote:
3 months ago
Hi
The error message has a typo, therefore the option doesn't work.
It should be plural (as you can see if you try it out in the error message you get)

option subsystems;

Hope this helps
Renger

Re: Solvers error when calling from MatLab

Posted: Tue Jul 03, 2018 7:24 pm
by xtssss
Sorry for the misleading, I introduce the typo myself.
My Gams version is 23.6.5, not that old...
But thanks for reminding me that it may because of the version.

xtssss.
Fred wrote:
3 months ago
Hi xtssss,

Actually, the error message should read

Unknown algorithm
The GAMS statement 'option subsystems;' will list
the installed subsystems in the GAMS listing file.

Maybe you introduced the typo yourself?
Is there a chance that from Matlab you are using a GAMS version older than 23.1.1? In this version COUENNE was introduced.

Best,
Fred

Re: Solvers error when calling from MatLab

Posted: Thu Jul 05, 2018 9:31 am
by Fred
Hi,

Now that you figured out that there was a typo, it seems like a natural next step to use "option subsystems;" without a typo and have a look at the output this option produces in the lst file.
Maybe you also can share the lst file here, so other users can have a look at it and may be able to help you.

Best,
Fred

Re: Solvers error when calling from MatLab

Posted: Fri Jul 13, 2018 6:56 pm
by xtssss
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 1
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n


1
Platooning CSG problem
FORMULATION
6 ****************************************
7 *Set, Data, and Parameters
8 ****************************************
9 *set
10 set I set of all vehicles
11 I1(I) set of all type 1 vehicles
12 I2(I)
13 I3(I)
14 J upper bound of set of all possible platoons /1*2000/
15 NI(J) set of all initial platoons
16 P set of all positions
17 K set of all possible patterns (regardless of private info
18 Q set of all vehicle types
19 *set for names
20 initialpar redcost and optimal speed
21 patternpar mk1 mk2 mk3 coe_A coe_B coe_C coe_D
22 *patternpar /1,2,3,4,5,6,7/
23 private_info1 sensbeta
24 private_info2 v_de
25 private_info3 original cost;
26 */oricost/;
27
28 *$onempty
29 * set I2(I) set of all type 2 vehicles / /
30 * I3(I) set of all type 3 vehicles / /;
31 *$offempty
32
33 parameter costandspeed(NI,initialpar)
34 initial_Amat(I,NI)
35 pattern (K,patternpar)
36 tablealpha(I,private_info1)
37 tablev_de(I,private_info2)
38 tableoricost(I,private_info3);
39
40 scalar miles /100/;
41
42
43 *subsection*******************
44 *Data Input
45 ******************************
GDXIN C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_CMEM\inputdat_pc.gdx
--- LOAD I = 1:I
--- LOAD I1 = 2:I1
--- LOAD I2 = 3:I2
--- LOAD I3 = 4:I3
--- LOAD NI = 5:NI
--- LOAD P = 6:P
--- LOAD K = 7:K
--- LOAD Q = 8:Q
--- LOAD initialpar = 9:initialpar
--- LOAD patternpar = 10:patternpar
--- LOAD private_info1 = 11:private_info1
--- LOAD private_info2 = 12:private_info2
--- LOAD private_info3 = 13:private_info3
48 *
50 *display NI,I,initialpar;
51
GDXIN C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_CMEM\inputdat_pc.gdx
--- LOAD costandspeed = 14:costandspeed
--- LOAD initial_Amat = 15:initial_Amat
--- LOAD pattern = 16:pattern
--- LOAD tablealpha = 17:tablealpha
--- LOAD tablev_de = 18:tablev_de
--- LOAD tableoricost = 19:tableoricost
55 *display costandspeed,pattern,tablev_de,tablealpha;
56
57 parameter alpha(I), v_de(I),oricost(I),epsilon;
58 alpha(I)=tablealpha(I,'sensbeta');
59 v_de(I)=tablev_de(I,'v_de')/3.6;
60 epsilon=1e-4;
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 2
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n


61 oricost(I)=tableoricost(I,'oricost');
62
63
64 ****************************************
65 *Master Problem_linear relaxed
66 ****************************************
67 *these parameters are self-generated by gams, no need to input.
68 parameter Amatrix(I,J)
69 cost(J)
70 valid(J)
71 v_opt(J)
72 break1
73 Variable mainvalue,x(J);
74
75 *Binary Variable x(J);
76
77 Equation main_obj, main_eq1,main_eq1c, main_eq2;
78
79 main_obj.. mainvalue=e=sum(J$valid(J), cost(J)*x(J));
80
81 main_eq1(I).. sum(J$valid(J), Amatrix(I,J)*x(J))=e=1;
82
83 main_eq2(J)$valid(J).. x(J)=g=0;
84
85 model master_model /main_obj,main_eq1,main_eq2/;
86
87 ****************************************
88 *Master Problem_original
89 ****************************************
90
91 Variable ori_mainvalue;
92 Binary variable ori_x(J);
93
94 *Binary Variable x(J);
95
96 Equation ori_main_obj, ori_main_eq1;
97
98 ori_main_obj.. ori_mainvalue=e=sum(J$valid(J), cost(J)*ori_x(J));
99
100 ori_main_eq1(I).. sum(J$valid(J), Amatrix(I,J)*ori_x(J))=e=1;
101
102
103 model ori_master_model /ori_main_obj,ori_main_eq1/;
104 ****************************************
105 *Master Problem-dual
106 ****************************************
107 Variable mainvalue_d,x_d(I);
108
109 *Binary Variable x(J);
110
111 Equation maind_obj, maind_eq1, maind_eq2;
112
113 maind_obj.. mainvalue_d=e=sum(I, x_d(I));
114
115 maind_eq1(J)$valid(J).. sum(I, Amatrix(I,J)*x_d(I))=L=cost(J);
116
117 maind_eq2(I).. x_d(I)=g=0;
118
119 model masterd_model /maind_obj,maind_eq1/;
120 *****************************************
121 *Sub Problem - linearized
122 *****************************************
123 parameters
124 curk,
125 m1_k,
126 m2_k,
127 m3_k,
128 coe_a,
129 coe_b,
130 coe_c,
131 coe_d;
132 Parameter y(I),y_d(J);
133
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 3
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n


134 Positive variable v, w(I);
135
136 v.lo=60/3.6;
137
138 v.up=130/3.6;
139
140 parameter vup;
141 vup=v.up;
142
143 Binary variable z(I);
144
145 Variable totalvalue;
146
147 Equation sub_obj, sub_eq1, sub_eq2, sub_eq3, sub_eq4, sub_eq5, sub_eq6;
148 *real reduction-z^ty
149 sub_obj.. totalvalue =e= sum(I,y(I)*z(I))
150 + (coe_a*power(v,2)+coe_b*v+coe_c+coe_d/v)*miles
151 + sum(I,alpha(I)*power(w(I),2))*miles
152 - 2*sum(I,alpha(I)*v_de(I)*w(I))*miles
153 + sum(I,alpha(I)*v_de(I)*v_de(I)*z(I))*miles
154 - sum(I,z(I)*oricost(I));
155
156 sub_eq1.. sum(I$(ord(I) le card(I1)), z(I)) =e= m1_k;
157
158 sub_eq2.. sum(I$(ord(I) le (card(I1)+card(I2)) and ord(I) gt card(I1)), z(I)) =e= m2_k;
159
160 sub_eq3.. sum(I$(ord(I) le card(I) and ord(I) gt (card(I1)+card(I2))), z(I)) =e= m3_k;
161
162 sub_eq4(I)..w(I) =l= vup*z(I);
163
164 sub_eq5(I).. w(I) =l= v;
165
166 sub_eq6(I).. w(I) =g= v-(1-z(I))*vup;
167
168 model sub_model /sub_obj,sub_eq1,sub_eq2,sub_eq3,sub_eq4,sub_eq5,sub_eq6/;
169
170
171 *****************************************
172 *Iteration
173 *****************************************
174
175
176 *subsection*****************
177 *Initialization
178 ****************************
179 parameter done,
180 main_value,
181 new_main_value,
182 diff,
183 iter,
184 j_nonvalid,
185 tv,
186 az,
187 v_optsub,
188 reduced(J),
189 flag(K);
190 done=0;
191
192 loop(NI,
193 loop(I,
194 Amatrix(I,J)$(ord(J) eq ord(NI))=initial_Amat(I,NI);
195 );
196 cost(J)$(ord(J) eq ord(NI))=costandspeed(NI,'redcost');
197 v_opt(J)$(ord(J) eq ord(NI))=costandspeed(NI,'v_opt');
198 );
199 valid(J)$(ord(J) le card(NI))=yes;
200 valid(J)$(ord(J) gt card(NI))=no;
201 *display Amatrix, cost;
202
203 solve master_model using LP maximizing mainvalue;
204 *find dual variable
205 y(I)=main_eq1.m(I);
206 main_value=mainvalue.l;
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 4
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n


207 display valid,y;
solve masterd_model using LP maximizing mainvalue_d;
*find dual variable
y_d(J)=maind_eq1.m(J);
y(I)=x_d.l(I);
main_value=mainvalue_d.l;
display y_d;
216 *subsubsection**************
217 *Iteration begins
218 ****************************
219 iter=0;
220 parameter h(K) model handles;
221 while (not done and iter <30,
222
223 iter=iter+1;
224 *subsubsection*******
225 *solve sub problems
226 *********************
227 ******solve sub problems
228 OPTION LIMROW=0, LIMCOL=0, SOLPRINT=ON, DECIMALS=4, OPTCR=1E-6,
229 SYSOUT=OFF, ITERLIM=9999999, RESLIM=9999999;
230 sub_model.solvelink=3;
231 loop(K,
232 * assign paramters
233 curk=ord(K);
234 m1_k=pattern(K,'mk1')$(ord(K) eq curk);
235 m2_k=pattern(K,'mk2')$(ord(K) eq curk);
236 m3_k=pattern(K, 'mk3')$(ord(K) eq curk);
237 coe_a=pattern(K, 'coe_A')$(ord(K) eq curk);
238 coe_b=pattern(K, 'coe_B')$(ord(K) eq curk);
239 coe_c=pattern(K, 'coe_C')$(ord(K) eq curk);
240 coe_d=pattern(K, 'coe_D')$(ord(K) eq curk);
241
242 * solve
243 OPTION MINLP=COUENNE;
**** $253
244 *OPTION MINLP=BONMIN;
245 solve sub_model using MINLP minimizing totalvalue;
**** $257
246 h(K)=sub_model.handle;
247 break1=0;
248 * tv(K)=totalvalue.l(K);
249 * az(I,K)=z.l(I,K);
250 * assign z to a, totalvalue+zy to cost
251 );
252 ******collection solutions of sub problems
253 Repeat
254 loop(K$handleCollect(h(K)),
255 tv(K)=totalvalue.l;
**** $141
256 az(I,K)=z.l(I);
**** $141
257 v_optsub(K)=v.l;
258 display$handledelete(h(K)) 'trouble deleting handles' ;
259 h(K) = 0 );
260 display$sleep(card(h)*0.2) 'sleep some time';
261 until card(h) =0;
262 tv(K)$h(K)=na;
263 az(I,K)$h(K)=na;
264 v_optsub(K)$h(K)=na;
265 ******pass sub problem solutions to master problem.
266 display tv;
267 loop (K,
268
269 break1=0;
270 if(tv(K) lt 0,
271 flag(K)=0;
if (tv(K) le -0.01,
flag(K)=0;
else
flag(K)=1;);
278 * find firstnonvalid
279 loop(J $ (not break1),
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 5
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n


280 if (not valid(J),
281 j_nonvalid=ord(J);
282 display j_nonvalid;
283 break1=1;);
284 );
285 cost(J)$(ord(J) eq j_nonvalid)=-(tv(K)-sum(I,y(I)*az(I,K)));
286 v_opt(J)$(ord(J) eq j_nonvalid)=v_optsub(K)*3.6;
287 valid(J)$(ord(J) eq j_nonvalid)=yes;
288 loop(I,
289 Amatrix(I,J)$(ord(J) eq j_nonvalid)=az(I,K));
290
291 else
292 flag(K)=1;
293 );
294 );
295
296 done=prod(K, flag(K));
297
298 *subsubsection*******
299 *solve main problem
300 *********************
301 *display cost, valid;
302 OPTION SYSOUT=ON;
303
304 solve master_model using LP maximizing mainvalue;
**** $257
305 *find dual variable
306 y(I)=main_eq1.m(I);
307 new_main_value=mainvalue.l;
308 display new_main_value,main_value;
solve masterd_model using LP maximizing mainvae
y_d(J)=maind_eq1.m(J);
y(I)=x_d.l(I);
new_main_value=mainvalue_d.l;
315 diff=new_main_value-main_value;
316 main_value=new_main_value;
317 display diff;
318 reduced(J)$(valid(J))=sum(I, Amatrix(I,J)*y(I))-cost(J);
319 display flag,done;
320 );
321 ori_x.l(J)=x.l(J);
322 ori_x.up(J)$(ord(J) le card(I))=0;
323 ori_mainvalue.l=new_main_value;
324 OPTION MIP=CPLEX;
325 solve ori_master_model using MIP maximizing ori_mainvalue;
**** $257
326 display ori_x.l,ori_mainvalue.l,new_main_value;
327 execute_unload 'outputdat_pc', ori_x,cost,v_opt,Amatrix,ori_mainvalue,new_main_value;

**** LIST OF STRAY NAMES - CHECK DECLARATIONS FOR SPURIOUS COMMAS
**** STRAY NAME main_eq1c OF TYPE EQU
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 6
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Error Messages


141 Symbol neither initialized nor assigned
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
253 Unknown algorithm
The GAMS statement 'option subsystems;' will list
the installed subsystems in the GAMS listing file.
257 Solve statement not checked because of previous errors

**** 6 ERROR(S) 0 WARNING(S)
GAMS Rev 232 WEX-WEI 23.2.1 x86_64/MS Windows 07/13/18 14:54:01 Page 7
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Include File Summary


SEQ GLOBAL TYPE PARENT LOCAL FILENAME

1 1 INPUT 0 0 C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_C
MEM\csg_newstop_grid_pc.gms
2 46 GDXIN 1 46 C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_C
MEM\inputdat_pc.gdx
3 52 GDXIN 1 52 C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_C
MEM\inputdat_pc.gdx


COMPILATION TIME = 0.000 SECONDS 3 Mb WEX232-232 Aug 11, 2009


USER: Civil and Coastal Engineering G100512:1957AP-WIN
University of Florida DC8384
License for teaching and research at degree granting institutions


**** FILE SUMMARY

Input C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_CMEM\csg_newstop_grid_pc.gms
Output C:\Users\barbi\Google Drive (Not Syncing)\2018 Winter\CACC\Models\ValuationFunc_CMEM\csg_newstop_grid_pc.lst

**** USER ERROR(S) ENCOUNTERED
Fred wrote:
2 months ago
Hi,

Now that you figured out that there was a typo, it seems like a natural next step to use "option subsystems;" without a typo and have a look at the output this option produces in the lst file.
Maybe you also can share the lst file here, so other users can have a look at it and may be able to help you.

Best,
Fred

Re: Solvers error when calling from MatLab

Posted: Sat Jul 14, 2018 10:12 am
by gamsadmin
Hi
It would be more useful if you attach the model you are trying to solve then letting us go through 500 lines looking for an error message.
And: you could also have done what Fred and I suggested: run a simple gams file with

Code: Select all

option subsystems
And show the output in your post to see if Couenne is installed or not.
Cheers
Renger