Hi,
I want to get the flag to see if the model is feasible or infeasible. I tried objects and classes from the tutorial but could not get it to work.
from gams import *
import os
cwd = os.getcwd()
filename='test_if_else.gms'
ws = GamsWorkspace(system_directory='/Applications/GAMS25.0/sysdir/')
gamscode="""
set i /1,2/;
positive variables
x(i)
y
;
variables
z
;
equations
obj
cons1
cons2
;
obj.. sum[i,x(i)]+y=e=z;
cons1.. 3*sum[i,x(i)]+2*y =g= %s;
cons2.. sum[i,x(i)]+y =l=1;
model test /obj, cons1, cons2/;
solve test using lp minimizing z;
model test2 /obj, cons1/;
if (test.modelStat =1,
display x.l,y.l;
elseif test.modelStat =4,
display "model finished with infeasibility";
solve test2 using lp minimizing z;
else
display "model is not correct";
)
display x.l,y.l;"""%str(5)
filename = "test_write.gms"
file_gams= open(filename,"w")
file_gams.write(gamscode)
file_gams.close()
t1=ws.add_job_from_file(cwd+'/'+filename)
t1.run()
variable_list=['x','y']
for v in variable_list:
for o in t1.out_db[v]:
print(o)
print("%s : "%v,o.marginal )
I appreciate if someone can help.
Thanks