ampl gurobi to store mulitple solutions

114 views
Skip to first unread message

Zhang Peng

unread,
Sep 4, 2018, 8:30:57 AM9/4/18
to am...@googlegroups.com

Hi,

 

I am using ampl with gurobi solver. I would like to retrieve the N best solutions. Could you please kindly suggest how to set the gurobi options.

As shown below, I have set the ams_mode and ams_limit to 2 and 10 respectively. However, only one solution is stored in the .txt file.

May I know how to retrieve the multiple solutions given by gurobi from AMPL?

 

---

reset;

 

model model1.mod;

data input1.dat;

 

param resultFile_Summary symbolic := "resmsg.txt";

 

option solver gurobi;

option gurobi_options 'ams_mode 2';

option gurobi_options 'ams_limit 10';

 

solve;

 

display x > (resultFile_Summary); # x is my decision variable in model1.mod. I expect to see 10 sets of x’s in the result file.

 

close (resultFile_Summary);

---

 

Thank you very much.

 

Best regards,

Peng

This e-mail and any attachments are only for the use of the intended recipient and may contain material that is confidential, privileged and/or protected by the Official Secrets Act. If you are not the intended recipient, please delete it or notify the sender immediately. Please do not copy or use it for any purpose or disclose the contents to any other person.

AMPL Google Group

unread,
Sep 4, 2018, 5:15:20 PM9/4/18
to Ampl Modeling Language
You need to set ams_stub option also. If you use the following option:
option gurobi_options 'ams_stub=poolgurobi ams_mode=2 ams_limit=10'; then Gurobi will try to produce 10 different files named poolgurobi0.sol, poolgurobi1.sol and so on. You need to use solution command to read the individual file in AMPL session. You could use following script to read and process the file

for {i in 1..<Objective_Name>.npool}
{
solution ("poolgurobi" & i & ".sol");
display Total_Cost;
}
Instead of display, you can use any processing commands you like. Make sure you have the latest version of AMPL. npool option is available from the AMPL released after 20180601.

--
Dr. Paras Tiwari
am...@googlegroups.com
{#HS:655958355-22051#}
On Tue, Sep 4, 2018 at 12:31 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Hi,


I am using ampl with gurobi solver. I would like to retrieve the N best solutions. Could you please kindly suggest how to set the gurobi options.
As shown below, I have set the ams_mode and ams_limit to 2 and 10 respectively. However, only one solution is stored in the .txt file.
May I know how to retrieve the multiple solutions given by gurobi from AMPL?


---

reset;

modelmodel1.mod;

datainput1.dat;

paramresultFile_Summary symbolic := "resmsg.txt";

optionsolver gurobi;

optiongurobi_options 'ams_mode 2';

optiongurobi_options 'ams_limit 10';

solve;

displayx > (resultFile_Summary); # x is my decision variable in model1.mod. I expect to see 10 sets of x's in the result file.

close(resultFile_Summary);
---


Thank you very much.


Best regards,
Peng
This e-mail and any attachments are only for the use of the intended recipient and may contain material that is confidential, privileged and/or protected by the Official Secrets Act. If you are not the intended recipient, please delete it or notify the sender immediately. Please do not copy or use it for any purpose or disclose the contents to any other person.--
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.



胡丹

unread,
Nov 28, 2018, 3:28:38 PM11/28/18
to AMPL Modeling Language

What if I would like to take each solution as a starting point for a nonlinear program. Let's say I would like to run "solve water" for each feasible solution and take the solution with the smallest objective value. 

在 2018年9月4日星期二 UTC-5下午4:15:20,AMPL Google Group写道:

AMPL Google Group

unread,
Nov 28, 2018, 10:43:18 PM11/28/18
to Ampl Modeling Language
I think this is the duplicate question. I have replied at https://secure.helpscout.net/conversation/719400507/30346?folderId=1837090. Let us know if you still have the problem.


--
Dr. Paras Tiwari
am...@googlegroups.com
{#HS:719385313-30339#}
Reply all
Reply to author
Forward
0 new messages