How to Call GLPK from AMPL

471 views
Skip to first unread message

Shailesh

unread,
Jan 4, 2017, 8:03:13 PM1/4/17
to AMPL Modeling Language
Hello,

I want to use GLPK solver-glpsol within AMPL. Do you know how should I call glpsol from AMPL ?

I tried using glpsol -m ampl.mod but that failed due to the syntax error.

Thank you.

Indrajit Sen Gupta

unread,
Jan 4, 2017, 8:27:19 PM1/4/17
to AMPL Modeling Language
Don't think it is possible to call glpk from AMPL. If you are using glpsol, from the commandline, it will work on its own.


Regards,
Indrajit

Robert Fourer

unread,
Jan 6, 2017, 4:55:13 PM1/6/17
to am...@googlegroups.com
GLPK does not have an AMPL interface. If you can use any free solver, then try downloading CBC for AMPL from http://ampl.com/products/solvers/open-source/; CBC handles the same kinds of problems as GLPK. If you must use GLPK, you can use the AMPL command "write mampl;" to write an MPS file named ampl.mps which you can send to GLPK; however you will not be able to read GLPK's results back into AMPL to view them, so option is of limited value.

Bob Fourer
am...@googlegroups.com

=======

Meketon, Marc

unread,
Jan 6, 2017, 6:17:21 PM1/6/17
to Shailesh, am...@googlegroups.com

There are several reasons why you might have a syntax error when running an AMPL model within GLPK.

 

(1)  The language in GLPK (called MathProg or GMPL) is a subset of AMPL, and lacks useful AMPL features such as node-arc modeling and command scripts (and a lot more).  See http://ampl.com/BOOK/CHAPTERS/18-network.pdf and http://ampl.com/BOOK/CHAPTERS/16-script.pdf

(2)  GMPL does differ in some details from AMPL even for the same type of statement (see, e.g., https://lists.gnu.org/archive/html/help-glpk/2005-05/msg00014.html)

 

An alternative is for you try to modify your model to fit within the GMPL.  If you get stuck, you might wish to communicate with the GLPK help group. See https://lists.gnu.org/mailman/listinfo/help-glpk

 

                                                                     

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of Shailesh
Sent: Wednesday, January 04, 2017 6:48 PM
To: AMPL Modeling Language
Subject: [AMPL 13300] How to Call GLPK from AMPL

 

Hello,

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



This e-mail and any attachments may be confidential or legally privileged. If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail. Thank you for your cooperation.

Shailesh

unread,
Jan 10, 2017, 9:16:26 AM1/10/17
to AMPL Modeling Language
Thank you, Robert, Marc, and Indrajit.

   As GLPK does not have an interface with AMPL, I tried CBC solver as per your suggestion, and it works fine. As I don't have any requirement to use GLPK, I stick with CBC. However, if any necessity initiates in the future, I will re-write my model in GMPL. 

Bence Bagi

unread,
Jan 16, 2017, 9:46:00 AM1/16/17
to AMPL Modeling Language
May I ask why you need an open-source solver when you have AMPL (and presumably the solvers available with it - that's just an assumption that you have multiple commercial solvers at hand)?
Reply all
Reply to author
Forward
0 new messages