embmihws.gms : ModelInstance hot/warmstart switch

Description

This model tests the switch for a hotstart to a warmstart from one mi.solve to the next.

Contributor: Michael Bussieck, January 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : embmihws.gms

$title ModelInstance hot/warmstart switch (EMBMIHWS,SEQ=886)

$onText
This model tests the switch for a hotstart to a warmstart from one mi.solve to the next.

Contributor: Michael Bussieck, January 2022
$offText


$log --- Using Python library %sysEnv.GMSPYTHONLIB%

$onEchoV > runm.gms
scalar a /2/, b/2/, c/4/;
Variable x,y,z;
Equation e1,e2,e3,obj;
e1..  sqr(x) + sqr(y) =l= c;
e2..  x =g= a;
e3..  y =l= b;
obj.. z =e= x + y;
model m /all/;
solve m max z us qcp;

embeddedCode Python:
def solveMI(mi, symIn=[], symOut=[]):
  for sym in symIn:
    gams.db[sym].copy_symbol(mi.sync_db[sym])
  mi.solve(output=sys.stdout)
  for sym in symOut:
    try:
      gams.db[sym].clear() # Explicitly clear the symbol to ensure setting "writtenTo" flag for sym
      mi.sync_db[sym].copy_symbol(gams.db[sym])
    except:
      pass
pauseEmbeddedCode
abort$execerror 'Python error. Check the log';

$libInclude pyEmbMI mMI 'm us qcp max z' -all_model_types=cplex a.Zero b.Zero c.Zero

continueEmbeddedCode:
solveMI(mMI,['a','b','c'],['x','y'])
pauseEmbeddedCode x y

a = 3; b = 4; c = 9;
continueEmbeddedCode:
solveMI(mMI,['a','b','c'],['x','y'])
pauseEmbeddedCode x y
$offEcho
$call.checkErrorLevel gams runm.gms lo=3 > runm.log
$call.checkErrorLevel grep -q "Hotstart failed" runm.log