GAMS [ Home | Support | Sales | Solvers | Documentation | Model Libraries | Search | Contact Us ]

gsolver.gms : Compare the actual system with the original solver database


This model compares the solvers and their capabilities on the
actual system with the original solver capability database.
It then runs all combinations with solvers known to the global database
and checks if the return code of a GAMS run is 0.

All exceptions are captured in a compare report. If the report is not empty,
the model will terminate with an execution error.

Reference:
Small Model of Type: GAMS
$Title Compare the actual system with the original solver database (GSOLVER,SEQ=311) $ontext This model compares the solvers and their capabilities on the actual system with the original solver capability database. It then runs all combinations with solvers known to the global database and checks if the return code of a GAMS run is 0. All exceptions are captured in a compare report. If the report is not empty, the model will terminate with an execution error. $offtext Sets ModelTypes / system.ModelTypes / SolverNames / system.SolverNames / Platforms / system.Platforms / glbSolverDB(SolverNames,ModelTypes,Platforms) / system.SolverTypePlatformMap / Set s(SolverNames) Solvers available for this platform glbSolverCapabilities(SolverNames,ModelTypes) original solver model type map Parameter comprep compare report; s(SolverNames) = sum(glbSolverDB(SolverNames,ModelTypes,'%system.platform%'), yes); glbSolverCapabilities(s,ModelTypes) = sum(glbSolverDB(s,ModelTypes,'%system.platform%'), yes); * Solver/Capability pairs missing in the actual system comprep(s,ModelTypes,'missing') = glbSolverCapabilities(s,ModelTypes) and not SolverCapabilities(s,ModelTypes); * Additional Solver/Capability pairs in the actual system comprep(s,ModelTypes,'additional') = not glbSolverCapabilities(s,ModelTypes) and SolverCapabilities(s,ModelTypes); $onempty set skiplist 'list of solvers to skip' / aecpwrap alphaecp decis oslse tramp $if %system.hostplatform% == WEX $goto do64 $if %system.hostplatform% == LEX $goto do64 $goto skip64 $label do64 $if %system.buildcode% == LX3 pathold $if %system.buildcode% == LX3 milesold $if %system.buildcode% == VIS pathold $if %system.buildcode% == VIS milesold $if %system.buildcode% == VIS osl1 $label skip64 ampl lingo decisc decism conoptd lindowrap lmbigm lmchull lmlboa /; $offempty * Produce a GAMS program that will execute and configure the test * models (shown at the end). For each solver model type combination * we will execute a program like: * * $call =gams <scratch dir>m.%gams.scrext% lo=0 --mtype=rmip --solver=conopt * $if errorlevel 1 $abort "Solver conopt expected to solve rmip"; * * and record exceptions in the 'fail' column of the report set tuple comprep. $set mname '"%gams.scrdir%m.%gams.scrext%"' file fx / rungslv.gms /; fx.lcase=1; file flog / '' /; flog.ps = 1; $set singlerun $set lo lo=0 $if set solver $set singlerun and sameas('%solver%',s) and sameas('%modeltype%',Modeltypes) $if set solver $set lo lo=3 loop(SolverCapabilities(s,ModelTypes)$([sum{skiplist(s),1}=0] %singlerun%), putclose fx '$call =gams %mname% %lo% --mtype=' ModelTypes.tl:0 ' --solver=' s.tl:0 / '$if errorlevel 1 $abort "Solver ' s.tl:0 ' expected to solve ' ModelTypes.tl:0; put flog '--- Running Solver ' s.tl:0 ' on Model Type ' ModelTypes.tl:0 / execute '=gams rungslv.gms %lo%'; comprep(s,ModelTypes,'fail')$errorlevel = yes; ); $if set solver $goto modeldump file ff / gslvfail.gms /; loop((s,ModelTypes)$comprep(s,ModelTypes,'fail'), put ff '$call gams gsolver --Solver ' s.tl:0 ' --ModelType ' ModelTypes.tl:0 /; ); * list of known failures to ignore: this should be empty, but . . . $onempty set ignorelist / coincbc /; $offempty comprep(ignorelist,modelTypes,'fail') = no; * Trigger an execution error if the comprep report has entries abort$card(comprep) comprep; $label modeldump * Below is the test program to be executed. Note that we * copy the model into the scratch directory with the name extension * .%gams.scrext%. This file will then be removed automatically when gams * terminates. $onechoV > %mname% * A tiny test model for all different model types * The $setddlist (Double Dash List) defines all * 'legal' --names. $if NOT set mtype $error --mtype=xxxx missing $if NOT set solver $error --solver=xxxx missing $setddlist mtype solver Variable z; Positive Variables w, x, y; x.up = 200; Integer Variables xi, yi; Equation lpe1, nlpe1, dnlpe1, mipe1, minlpe1, lpo, qcpo, nlpo, mipo, miqcpo, minlpo cnse1, cnse2, mcpe1, mpeco, dece1, deco; * LP QCP NLP MIP MIQCP MINLP lpe1.. x + y =l= 2.2; nlpe1.. exp(x+y) =l= 4.1; dnlpe1.. abs(x*y) =l= 4.1; mipe1.. xi + yi =l= 3.5; minlpe1.. exp(xi*yi) =l= 4.6; lpo.. z =e= -3*x - 4*y; qcpo.. z =e= 2*sqr(x - 3.4) + 3*sqr(y - 2.9); nlpo.. z =e= exp(3*x + 2*y); mipo.. z =e= -3*xi - 4*yi; miqcpo.. z =e= 2*sqr(xi - 3.4) + 3*sqr(yi - 2.9); minlpo.. z =e= exp(3*xi + 2*yi); * CNS cnse1.. sqr(x-3) + sqrt(y+4) =e= 3.7; cnse2.. x + 3.1*y =e= 3.5; * MPEC and MCP mcpe1.. 0.5*x + 2*y =g= 100; mpeco.. z =e= 0.5*sqr(x) + 0.5*x*y - 95*x; * DECIS dece1.. x =e= y + w; deco.. z =e= 24*y -2.49*x - 4*w; model m_lp / lpe1, lpo / m_qcp / lpe1, qcpo / m_nlp / nlpe1, nlpo / m_dnlp / dnlpe1, nlpo / m_rmip / mipe1, mipo / m_mip / mipe1, mipo / m_rmiqcp / mipe1, miqcpo / m_miqcp / mipe1, miqcpo / m_rminlp / minlpe1, minlpo / m_minlp / minlpe1, minlpo / m_cns / cnse1, cnse2 / m_mpec / mcpe1.y, mpeco / m_rmpec / mcpe1.y, mpeco / m_mcp / mcpe1.y / m_decis / dece1, deco /; option %mtype%=%solver%, optcr=0; * Special handling for model types that do not have an objective $ifi %mtype% == cns $goto CNS $ifi %mtype% == mcp $goto MCP * Special handling of solvers with special requirements $ifi %solver% == decisc $goto DECIS $ifi %solver% == decism $goto DECIS $ifi %solver% == oslse $goto OSLSE $ifi %solver% == dea $goto DEA $ifi %solver% == ls $goto LS solve m_%mtype% using %mtype% min z; abort$(m_%mtype%.solvestat <> 1) 'solver return not normal'; $exit $label CNS solve m_cns using cns; abort$(m_cns.solvestat <> 1) 'solver return not normal'; $exit $label MCP x.fx=200; solve m_mcp using mcp; abort$(m_mcp.solvestat <> 1) 'solver return not normal'; $exit $label DECIS y.up = 160; x.stage=1; dece1.stage=2; y.stage=2; file fx / MODEL.STG / fy / MINOS.SPC /; putclose fx 'BLOCKS DISCRETE' / 'BL BLOCK1 PERIOD2 0.25' / 'UP BND y 150' / 'BL BLOCK1 PERIOD2 0.75' / 'UP BND y 160'; putclose fy 'begin' / 'rows 250' / 'columns 250' / 'elements 10000' / 'end'; solve m_decis using %mtype% max z; abort$(m_decis.solvestat <> 1) 'solver return not normal'; $exit $label OSLSE set n nodes / r, 1, 2 /, leaf(n) / 1, 2 /, root(n) / r / Variables sex(n) Equations seo, seg(n), sef(n); seo.. sum (leaf, sex(leaf)) =e= z; sef(root).. sex(root) =l= 1; seg(leaf).. sex(leaf) =e= sex('r') + 1; model m_oslse / sef, seg, seo /; solve m_oslse using %mtype% max z; abort$(m_oslse.solvestat <> 1) 'solver return not normal'; $exit $label DEA Sets i / d1*d2 /, j / i1, o1 /, ji(j) / i1 /, jo(j) / o1 /; Parameter d(i,j) / d1.i1 3, d1.o1 5, d2.i1 2.5, d2.o1 4.5 /; Positive variables v(ji), u(jo); alias (slice,i); Equations deao(slice), deae1(slice), deae2(i); deao(i).. z =e= sum(jo, u(jo)*d(i,jo)); deae1(i).. sum(ji, v(ji)*d(i,ji)) =e= 1; deae2(i).. sum(jo, u(jo)*d(i,jo)) =l= sum(ji, v(ji)*d(i,ji)); model m_dea /deao, deae1, deae2/; solve m_dea using %mtype% max z; abort$(m_dea.solvestat <> 1) 'solver return not normal'; $exit $label LS set i 'cases' /i1*i4/; set p 'coefficients' / p0, p1 /; Scalars d; parameters ls_b_(p) / p0 1, p1 1 / ls_y(i), ls_x(i) se_(p) 'Standard errors' / 'p0' 0.295803989154981 'p1' 0.158113883008419 / se(p) 'Standard errors' ; ls_x(i) = ord(i)-1; ls_y(i) = ls_b_('p0') + ls_x(i) * ls_b_('p1') + 0.25$[sameas(i,'i1') or sameas(i,'i4')] - 0.25$[sameas(i,'i2') or sameas(i,'i3')]; variables ls_b(p) sse 'sum of squared errors' ; equation fit(i) 'equation to fit' sumsq ; sumsq.. sse =n= 0; fit(i).. ls_y(i) =e= ls_b('p0') + ls_x(i) * ls_b('p1'); option lp = ls; model leastsq /fit,sumsq/; solve leastsq using lp minimizing sse; abort$(leastsq.solvestat <> 1) 'solver return not normal'; d = smax{p, abs(ls_b.l(p)-ls_b_(p))}; abort$[d > 1e-8] 'bad solution ls_b.l', ls_b.l, ls_b_, d; execute_load 'ls', se; abort$[execerror > 0] 'Could not load statistics from GDX'; d = smax{p, abs(se_(p) - se(p))}; abort$[d > 1e-8] 'bad standard error', se_, se, d; $exit $offecho