SolverStudio supports the GNU optimisation package GLPK and associated GMPL modelling language which is (roughly) a subset of AMPL. Please see the “AMPL(NEOS)+GMPL Examples.xlsx” spreadsheet in the SolverStudio download for example code.

Please note that GMPL lacks AMPL’s nice output, and so the following more complicated code is needed to output results from GMPL:

1 2 3 4 5 6 7 8 9 10 11 |
# Write the solution to the sheet (copying AMPL's display format) # Each item is quoted to ensure spaces in items work correctly printf "" > "Sheet"; # Open output file printf "flow :=\n" >> "Sheet"; printf {i in Warehouses, j in Bars}: "'%s' '%s' '%s'\n", i, j, flow[i,j] >> "Sheet"; printf ";\n" >> "Sheet"; # A single value can be written as follows (again mimicing AMPL) printf "Total_Cost = " >> "Sheet"; printf Total_Cost >> "Sheet"; printf "\n" >> "Sheet"; |

**Useful GMPL links include:**

GLPK/MathProg for Natural Resources (Forestry, Agriculture,…)

GMPL Wiki Pages and GLPK Wiki Pages

GLPK for Windows including 32 and 64 bit executables and GLPK for Java

Hi Andrew,

The GMPL/GLPK included in the SolverStudio 0.09.03 (20160520) does not seem to have support for GNU Scientific Library (GSL), unlike AMPL which does support it through amplgsl.dll and related ‘function’ declaration. Is there a workaround for this? Thanks, Suresh.

I don’t know, sorry. I suggest you ask the GMPL folks directly. Andrew

I have now got the code working:

printf “” > “Sheet”; # Open output file

printf “ShortageSurplusDisruption = ” >> “Sheet”; # This line is needed

printf ShortageSurplusDisruption >> “Sheet”;

Alistair: GMPL lacks the nice AMPL output commands, and so, yes, in GMPL you need to do more work yourself. How can I make this clearer in the GMPL documentation and examples? Andrew

Hi Andrew.

My GMPL objective function is called ShortageSurplusDisruption and has value 11.52 after solving optimally. The command:

printf “%g”, ShortageSurplusDisruption;

works and outputs 11.52 but the command:

printf “%g”, ShortageSurplusDisruption > “Sheet”

causes an error, even though there an Excel cell with name ShortageSurplusDisruption.

The error message is:

Error executing model code: A value was written to the sheet for data item “11.52”, but this data item does not exist.

(The error occurred in the string ‘11.52’ on line 1 of file ‘Sheet.)

Traceback (most recent call last): File “G:\Downloads\SolverStudio\SolverStudio\SolverStudio\GLPK\RunGLPS ol.py”, line 376, in File “G:\Downloads\SolverStudio\SolverStudio\SolverStudio\GLPIC\RunGLPS ol.py”, line 302, in DoRun Exception: A value was written to the sheet for data item “11.52”, but this data item does not exist.

(The error occurred in the string ‘11.52’ on line 1 of file ‘Sheet’.)

Hi

i am having a problem, my model runs for a very long time, although it finds a solution it still running, i would like to stop it when it have found one solution and not wait until it finds the best.

Thanks.

Regards, Richard.

I suggest you look up the GMPL documentation in how to set a time limit and/or a tolerance for the branch and bound. Andrew

Hello,

I would understand what:

1)i should to do to use on SolverStudio Gnu (what i had to dowlaoad and if is necessary to have Linux on my pc)

2)are the limits of Gnu (if the solver could eventually solve MLI problems and also if can solve quadratic objective function)

3)where can i find examples of application problems of Gnu on SolverStudio.

Thanks so much!

Examples are included in the download. Linux is not needed. See the gmpl documentation for its capabilities. Good luck. Andrew

First, I would like to say that SolverStudio is a fantastic tool. I enjoy using it to solve optimization problems.

I am having a problem with outputting my results. I would like to output my objective function value to the sheet.

The following code prints my objective function value to the Model Output

printf “TotalWaitingTime :=\n”;

printf : “‘%s’\n”, TotalWaitingTime;

printf “;\n”;

When I change my code to the following

printf “TotalWaitingTime :=\n” >> “Sheet”;

printf : “‘%s’\n”, TotalWaitingTime >> “Sheet”;

printf “;\n” >> “Sheet”;

I receive an error that states: “the line “‘-105’\n” did not contain an index and a value.”

Note: -105 is the objective function value

The objective function is not supposed to have any indices. Do you know how I can print the objective function value to the sheet?

Thank you

Try this; it works for me.

# A single value can be written as follows (again mimicin AMPL)

printf “Total_Cost = ” >> “Sheet”;

printf Total_Cost >> “Sheet”;

printf “\n” >> “Sheet”;

Andrew

PS: You might like to contact the the GMPL author via [email protected] or [email protected] to suggest that GMPL be updated to support using >> in display statements.

Hi Andrew,

Nice to see support for GLPK/Mathprog (GPLK and GMPL) in SolverStudio.

If I am not mistaken, this support uses only GLPK solver (i.e. glpsol), right?

I wish to see support for Mathprog (GMPL) using CBC solver in SolverStudio, so we could take advantage to solve difficult MIP model with CBC solver.

GMPL can use CBC solver with limited result outputs. Here’s the link below.

http://en.wikibooks.org/wiki/GLPK/Mixing_GLPK_with_other_solver_packages

Thanks.

Regards, Noli

Noli. Thanks for the positive feedback. Yes, allowing GMPL with CBC has been on the TODO list for a while. We plan to re-visit this over Christmas when I hope to have a student working on the code. Cheers, Andrew

Hi Andrew,

I am using this code to run GMPL with CBC

@echo off

SET INPUT=input.mod

SET OUTPUT=out.txt

glpsol.exe –math %INPUT% –check –wlp _glpsol2cbc.lp

cbc.exe _glpsol2cbc.lp solve -gsolution _cbc2glpsol.lp

glpsol.exe –math %INPUT% –read _cbc2glpsol.lp –output %OUTPUT%

pause

del _*.lp

Thanks for that. We have just added this functionality into SolverStudio, complete with a menu to make choosing the preferred solver easy. I hope it will be useful. Andrew

Hi Andrew,

I am having a little trouble using the CBC solver with GMPL. When I try choosing that solver it doesnt seem to recognise what is the model or data file. Can you let me know what the steps would be to use the CBC solver with GMPL.

Thanks for all your help

GMPL cannot use CBC, sorry, within SolverStudio. You can compile your own GMPL-friendly version of CBC; however we have not done this. Andrew