relaxing integrality in gurobi

665 views
Skip to first unread message

Vivi

unread,
Oct 3, 2020, 1:59:33 AM10/3/20
to AMPL Modeling Language
Dear Robert,

I'm using GUROBI solver and I would like to put directives for relaxing integrality in my model. I'm writing to you to know how to proceed.
Many thanks in advance for your help.

Best regards.

AMPL Google Group

unread,
Oct 4, 2020, 10:07:44 AM10/4/20
to AMPL Modeling Language
There are two ways to relax integrality of all variables defined as "integer" or "binary". (1) You can tell Gurobi to relax integrality, by giving the command

option gurobi_options 'relax=1';

or by adding relax=1 to a gurobi_options string that you are already specifying. (2) You can tell AMPL to relax integrality by giving the command

option relax_integrality 1;

These may give different results, because (2) relaxes integrality before AMPL's presolve phase is run, while (1) runs AMPL's presolve on the integer problem and then relaxes integrality in Gurobi.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/e0ed590e-c5a3-41ec-8b60-601b5fa4b106o%40googlegroups.com.

Vivi

unread,
Oct 4, 2020, 8:13:57 PM10/4/20
to AMPL Modeling Language
Hi Robert,

Thank you very much for those useful informations!

Best regards.

Le dimanche 4 octobre 2020 10:07:44 UTC-4, AMPL Google Group a écrit :
There are two ways to relax integrality of all variables defined as "integer" or "binary". (1) You can tell Gurobi to relax integrality, by giving the command

option gurobi_options 'relax=1';

or by adding relax=1 to a gurobi_options string that you are already specifying. (2) You can tell AMPL to relax integrality by giving the command

option relax_integrality 1;

These may give different results, because (2) relaxes integrality before AMPL's presolve phase is run, while (1) runs AMPL's presolve on the integer problem and then relaxes integrality in Gurobi.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Sat, Oct 3, 2020 at 5:59 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

I'm using GUROBI solver and I would like to put directives for relaxing integrality in my model. I'm writing to you to know how to proceed.
Many thanks in advance for your help.

Best regards.
--
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 am...@googlegroups.com.

Vivi

unread,
Oct 10, 2020, 5:01:48 PM10/10/20
to am...@googlegroups.com
Dear Robert,

I'm writing to you concerning my AMPL model which takes a long time without solving. The problem concerns location of satellites among potential sites to serve customers. When I solve the model with 4 satellites and 10 customers to serve, AMPL solves the problem and I get results. But when I increase the number of satellites and customeers to try to solve the model with 8 satellites and 20 customers, AMPL  runs for a long time without giving a solution. I'am wriring to you to ask you if you can help me with this.
I also want to ask you if I can send you the model and data iin the form of private message because as this is a model concerning a paper I would like to publish I would like to keep it confidential.

Please receive my best regards.

Viviane


Le dimanche 4 octobre 2020 10:07:44 UTC-4, AMPL Google Group a écrit :
There are two ways to relax integrality of all variables defined as "integer" or "binary". (1) You can tell Gurobi to relax integrality, by giving the command

option gurobi_options 'relax=1';

or by adding relax=1 to a gurobi_options string that you are already specifying. (2) You can tell AMPL to relax integrality by giving the command

option relax_integrality 1;

These may give different results, because (2) relaxes integrality before AMPL's presolve phase is run, while (1) runs AMPL's presolve on the integer problem and then relaxes integrality in Gurobi.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Sat, Oct 3, 2020 at 5:59 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

I'm using GUROBI solver and I would like to put directives for relaxing integrality in my model. I'm writing to you to know how to proceed.
Many thanks in advance for your help.

Best regards.
--
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 am...@googlegroups.com.

AMPL Google Group

unread,
Oct 10, 2020, 7:57:34 PM10/10/20
to AMPL Modeling Language
Before you send any files, please do the following. Before your "solve" add the command

option gurobi_options 'outlev=1 timelim=12000';

(or if you are already defining a gurobi_options string, add outlev=1 and timelim=12000 to it). This tells Gurobi to run for 200 minutes and to display a detailed log of its progress. After Gurobi finishes, copy all of Gurobi's output and paste it into an email back to this forum. That should provide a lot of valuable information that can be used to give you some advice.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Sat, Oct 10, 2020 at 9:01 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

I'm writing to you concerning my AMPL model which takes a long time without solving. The problem concerns location of satellites among potential sites to serve customers. When I solve the model with 4 satellites and 10 customers to serve, AMPL solves the problem and I get results. But when I increase the number of satellites and customeers to try to solve the model with 8 satellites and 20 customers, AMPL runs for a long time without giving a solution. I'am wriring to you to ask you if you can help me with this.
I also want to ask you if I can send you the model and data iin the form of private message because as this is a model concerning a paper I would like to publish I would like to keep it confidential.

Please receive my best regards.

Viviane
On Mon, Oct 5, 2020 at 12:14 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Robert,

Thank you very much for those useful informations!

Best regards.

On Sun, Oct 4, 2020 at 2:07 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
There are two ways to relax integrality of all variables defined as "integer" or "binary". (1) You can tell Gurobi to relax integrality, by giving the command

option gurobi_options 'relax=1';

or by adding relax=1 to a gurobi_options string that you are already specifying. (2) You can tell AMPL to relax integrality by giving the command

option relax_integrality 1;

These may give different results, because (2) relaxes integrality before AMPL's presolve phase is run, while (1) runs AMPL's presolve on the integer problem and then relaxes integrality in Gurobi.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 11, 2020, 7:01:12 PM10/11/20
to AMPL Modeling Language
Hi Robert,

Thank you very much for your reply.

I already have in my statement the command :option gurobi_options 'nonconvex=2 outlev=0';

Must I replace outlev=0 by outlev=1? Can you please tell me how I can add the command you tell me to add to this command I already have?

Please received my best regards.

Viviane

AMPL Google Group

unread,
Oct 12, 2020, 12:04:14 PM10/12/20
to AMPL Modeling Language
You should replace outlev=0 by outlev=1, and add timelim=12000:

option gurobi_options 'nonconvex=2 outlev=1 timelim=12000';


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Sun, Oct 11, 2020 at 11:01 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Robert,

Thank you very much for your reply.

I already have in my statement the command :option gurobi_options 'nonconvex=2 outlev=0';

Must I replace outlev=0 by outlev=1? Can you please tell me how I can add the command you tell me to add to this command I already have?

Please received my best regards.

Viviane

On Sat, Oct 10, 2020 at 11:57 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Before you send any files, please do the following. Before your "solve" add the command

option gurobi_options 'outlev=1 timelim=12000';

(or if you are already defining a gurobi_options string, add outlev=1 and timelim=12000 to it). This tells Gurobi to run for 200 minutes and to display a detailed log of its progress. After Gurobi finishes, copy all of Gurobi's output and paste it into an email back to this forum. That should provide a lot of valuable information that can be used to give you some advice.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 12, 2020, 1:25:21 PM10/12/20
to AMPL Modeling Language
Thank you very much Robert.

Vivi

unread,
Oct 12, 2020, 10:56:15 PM10/12/20
to am...@googlegroups.com
Dear Robert,

As you aks me to do, please find attached the word file contening gurobi's output.
Please received my best regards.

Viviane
Gurobi_output_Viviane_A.docx

AMPL Google Group

unread,
Oct 15, 2020, 9:57:09 AM10/15/20
to AMPL Modeling Language
Dear Viviane,

Thank you for sending this log. We see that Gurobi was not able to make any progress. After 200 minutes, it was still not close to solving the continuous relaxation of the problem, which is only the first step after the presolve reductions. The message "Warning: 1 variables dropped from basis" suggests that there is some trouble with the numerical accuracy of the computations; in fact the log looks normal until the first time where this message appears.

Nonconvex quadratic programs are the hardest class of problems that Gurobi accepts, but still we would expect Gurobi to do better than this. At this point, we would like to examine your files to see whether a change to the formulation or the algorithmic options might help. If not, then the problem can be sent to the experts at Gurobi Optimization for more detailed study.

You can upload your files to a private folder by going to this page: https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Tue, Oct 13, 2020 at 2:56 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

As you aks me to do, please find attached the word file contening gurobi's output.
Please received my best regards.

Viviane
On Mon, Oct 12, 2020 at 5:25 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thank you very much Robert.

On Mon, Oct 12, 2020 at 4:03 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You should replace outlev=0 by outlev=1, and add timelim=12000:

option gurobi_options 'nonconvex=2 outlev=1 timelim=12000';


--
Robert Fourer
am...@googlegroups.com
On Sun, Oct 11, 2020 at 11:01 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Robert,

Thank you very much for your reply.

I already have in my statement the command :option gurobi_options 'nonconvex=2 outlev=0';

Must I replace outlev=0 by outlev=1? Can you please tell me how I can add the command you tell me to add to this command I already have?

Please received my best regards.

Viviane
On Sat, Oct 10, 2020 at 11:57 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Before you send any files, please do the following. Before your "solve" add the command

option gurobi_options 'outlev=1 timelim=12000';

(or if you are already defining a gurobi_options string, add outlev=1 and timelim=12000 to it). This tells Gurobi to run for 200 minutes and to display a detailed log of its progress. After Gurobi finishes, copy all of Gurobi's output and paste it into an email back to this forum. That should provide a lot of valuable information that can be used to give you some advice.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 16, 2020, 12:47:48 PM10/16/20
to am...@googlegroups.com
Dear Robert,

Many thanks for your help.
I'm going to try to decompose the model in two parts. When I will get results for the first part, I'm going to fix those results for the second part. I'm going to try this, if it doesn't work, then I'm going to drop the file in the link you have provided to ask for support from Gurobi's experts.

To do this, I would like to ask you for example if I have already results for arcs variables Xij from the first part of the model, how can I transmit those fixed results to AMPL using Gurobi, by using a spreadsheet file.

And also I would like to know How can I issue the final result resulting from the solving of the model as form as spreadheet file.

Please receive my best regards.

Viviane

AMPL Google Group

unread,
Oct 16, 2020, 3:47:02 PM10/16/20
to AMPL Modeling Language
For reading and writing spreadsheet values, see our AMPL Direct Spreadsheet Interface page.

If you are going to solve the two parts in different AMPL sessions, you can write the Xij values from the first part into a spreadsheet, and then read those values from the spreadsheet into parameters for the second part.

If you want to solve the two parts in the same AMPL session, using two solve commands, then you can use a combination of fix/unfix and drop/restore commands to transition from the first part to the second part, or you can define a different AMPL named problem for each part.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Fri, Oct 16, 2020 at 4:47 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

Many thanks for your help.
I'm going to try to decompose the model in two parts. When I will get results for the first part, I'm going to fix those results for the second part. I'm going to try this, if it doesn't work, then I'm going to drop the file in the link you have provided to ask for support from Gurobi's experts.

To do this, I would like to ask you for example if I have already results for arcs variables Xij from the first part of the model, how can I transmit those fixed results to AMPL using Gurobi, by using a spreadsheet file.

And also I would like to know How can I issue the final result resulting from the solving of the model as form as spreadheet file.

Please receive my best regards.

Viviane
On Thu, Oct 15, 2020 at 1:56 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Dear Viviane,

Thank you for sending this log. We see that Gurobi was not able to make any progress. After 200 minutes, it was still not close to solving the continuous relaxation of the problem, which is only the first step after the presolve reductions. The message "Warning: 1 variables dropped from basis" suggests that there is some trouble with the numerical accuracy of the computations; in fact the log looks normal until the first time where this message appears.

Nonconvex quadratic programs are the hardest class of problems that Gurobi accepts, but still we would expect Gurobi to do better than this. At this point, we would like to examine your files to see whether a change to the formulation or the algorithmic options might help. If not, then the problem can be sent to the experts at Gurobi Optimization for more detailed study.

You can upload your files to a private folder by going to this page: https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 18, 2020, 1:40:06 AM10/18/20
to am...@googlegroups.com
Hi Robert,
Well noted. Many thanks!

Vivi

unread,
Oct 19, 2020, 12:01:35 AM10/19/20
to am...@googlegroups.com
Hi Mr Robert,

I have uploaded my model and the result obtained to the private folder you have provided to me (https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv).

It is not for the analyse of the file by GUROBI's experts. It is beacause I have an issue with fix/unfix AMPL command.

I would like to fix the value of the following variables:Y,  X_F1,  X_F2, ND_NS,  Z, U_F1, U_F2, CHARG_F1, CHARG_F2, DEM_NS, DEM_ND.

The results I have obtained for those variables are in a file which I have also uploaded to the private folder.

As the variable Y,  X_F1,  X_F2, ND_NS, DEM_NS, DEM_ND appear also in the objectif function, I can not treat them as parameters for solving the second part of the model as the second part is made of constraints subject to the same objectif function.

Variables  X_F1,  and X_F2, appear in results as a lot of data I would like to aks you how I can write them to tell gurobi that want to fix them.

While excepting on your help, please receive my best regards.

Viviane

AMPL Google Group

unread,
Oct 19, 2020, 10:58:58 AM10/19/20
to AMPL Modeling Language
I see that you have used the display command to create your result file. To make the output of display readable, add the keyword var before it:

print "var" >result_v_essai_file.out;
display X_F1, X_F2 >result_v_essai_file.out;


Then in a later AMPL session, you can use a data statement to read the values back from the result file, and fix the variables at their previous values:

data result_v_essai_file.out;
fix X_F1;
fix X_F2;


I have shown this example with only one display statement and two variables, but you can easily extend it to all of the variables that you want to fix.

This approach is relevant if you solve the first model, then reset or leave AMPL. It lets you later load the second model and fix some variables at their values from the first solve, before solving the second time. (If you solve both models in the same AMPL session (without any reset) then only the fix commands are needed.)


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Mon, Oct 19, 2020 at 4:01 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I have uploaded my model and the result obtained to the private folder you have provided to me (https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv).

It is not for the analyse of the file by GUROBI's experts. It is beacause I have an issue with fix/unfix AMPL command.

I would like to fix the value of the following variables:Y, X_F1, X_F2, ND_NS, Z, U_F1, U_F2, CHARG_F1, CHARG_F2, DEM_NS, DEM_ND.

The results I have obtained for those variables are in a file which I have also uploaded to the private folder.

As the variable Y, X_F1, X_F2, ND_NS, DEM_NS, DEM_ND appear also in the objectif function, I can not treat them as parameters for solving the second part of the model as the second part is made of constraints subject to the same objectif function.

Variables X_F1, and X_F2, appear in results as a lot of data I would like to aks you how I can write them to tell gurobi that want to fix them.

While excepting on your help, please receive my best regards.

Viviane

On Sun, Oct 18, 2020 at 5:40 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Robert,
Well noted. Many thanks!

On Fri, Oct 16, 2020 at 7:46 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
For reading and writing spreadsheet values, see our AMPL Direct Spreadsheet Interface page.

If you are going to solve the two parts in different AMPL sessions, you can write the Xij values from the first part into a spreadsheet, and then read those values from the spreadsheet into parameters for the second part.

If you want to solve the two parts in the same AMPL session, using two solve commands, then you can use a combination of fix/unfix and drop/restore commands to transition from the first part to the second part, or you can define a different AMPL named problem for each part.


--
Robert Fourer
am...@googlegroups.com
On Fri, Oct 16, 2020 at 4:47 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

Many thanks for your help.
I'm going to try to decompose the model in two parts. When I will get results for the first part, I'm going to fix those results for the second part. I'm going to try this, if it doesn't work, then I'm going to drop the file in the link you have provided to ask for support from Gurobi's experts.

To do this, I would like to ask you for example if I have already results for arcs variables Xij from the first part of the model, how can I transmit those fixed results to AMPL using Gurobi, by using a spreadsheet file.

And also I would like to know How can I issue the final result resulting from the solving of the model as form as spreadheet file.

Please receive my best regards.

Viviane
On Thu, Oct 15, 2020 at 1:56 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Dear Viviane,

Thank you for sending this log. We see that Gurobi was not able to make any progress. After 200 minutes, it was still not close to solving the continuous relaxation of the problem, which is only the first step after the presolve reductions. The message "Warning: 1 variables dropped from basis" suggests that there is some trouble with the numerical accuracy of the computations; in fact the log looks normal until the first time where this message appears.

Nonconvex quadratic programs are the hardest class of problems that Gurobi accepts, but still we would expect Gurobi to do better than this. At this point, we would like to examine your files to see whether a change to the formulation or the algorithmic options might help. If not, then the problem can be sent to the experts at Gurobi Optimization for more detailed study.

You can upload your files to a private folder by going to this page: https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 19, 2020, 6:47:15 PM10/19/20
to AMPL Modeling Language
Hi Mr Robert,

Many many thanks for your help!

Viviane

Vivi

unread,
Oct 20, 2020, 5:27:45 PM10/20/20
to am...@googlegroups.com
Hi Mr Robert,

I split the model into two parts but it still spins for a long time with no results.

I am writing to you to find out if it is still possible to have it analyzed by the experts of Gurobi.

I have uploaded the model, data and run files to the private link you have provided to me.

 While waiting for your reply, please received my best regards.

Viviane

Vivi

unread,
Oct 20, 2020, 6:43:31 PM10/20/20
to am...@googlegroups.com
Hi Mr Robert,

I write to you again because I have uploaded a wrong run file. The right one is the last one I have uploaded that is Loca_cdu_8_20_essai_2.run

Thank very much for all you do to help me.

Best regards

Viviane

Vivi

unread,
Oct 20, 2020, 10:19:40 PM10/20/20
to am...@googlegroups.com
Dear Robert,

I'm writing to you to not to consider the previous version of files I have uploaded for gurobi Analyse.
Please consider only this last folder.

Best regards

Viviane

AMPL Google Group

unread,
Oct 25, 2020, 1:16:20 PM10/25/20
to AMPL Modeling Language
I have sent the experts at Gurobi Optimization an "MPS form" representation of your optimization problem that should enable them to reproduce the errors that we are seeing. (They will not have to look at your actual model.) I will provide an update after I get a reply.

The quadratic terms in your model are of the form "general-variable * binary-variable" which is a special case the can be linearized; see for example Paul Rubin's blog on Binary Variables and Quadratic Terms. These linearizations should be performed automatically by Gurobi, but if necessary -- depending on the reply from the Gurobi experts -- some of them could be done in the AMPL model.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Wed, Oct 21, 2020 at 2:19 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

I'm writing to you to not to consider the previous version of files I have uploaded for gurobi Analyse.
Please consider only this last folder.

Best regards

Viviane
On Tue, Oct 20, 2020 at 10:43 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I write to you again because I have uploaded a wrong run file. The right one is the last one I have uploaded that is Loca_cdu_8_20_essai_2.run

Thank very much for all you do to help me.

Best regards

Viviane

On Tue, Oct 20, 2020 at 9:27 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I split the model into two parts but it still spins for a long time with no results.

I am writing to you to find out if it is still possible to have it analyzed by the experts of Gurobi.

I have uploaded the model, data and run files to the private link you have provided to me.

While waiting for your reply, please received my best regards.

Viviane

On Mon, Oct 19, 2020 at 10:47 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

Many many thanks for your help!

Viviane

On Mon, Oct 19, 2020 at 2:58 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I see that you have used the display command to create your result file. To make the output of display readable, add the keyword var before it:

print "var" >result_v_essai_file.out;
display X_F1, X_F2 >result_v_essai_file.out;


Then in a later AMPL session, you can use a data statement to read the values back from the result file, and fix the variables at their previous values:

data result_v_essai_file.out;
fix X_F1;
fix X_F2;


I have shown this example with only one display statement and two variables, but you can easily extend it to all of the variables that you want to fix.

This approach is relevant if you solve the first model, then reset or leave AMPL. It lets you later load the second model and fix some variables at their values from the first solve, before solving the second time. (If you solve both models in the same AMPL session (without any reset) then only the fix commands are needed.)


--
Robert Fourer
am...@googlegroups.com
On Mon, Oct 19, 2020 at 4:01 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I have uploaded my model and the result obtained to the private folder you have provided to me (https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv).

It is not for the analyse of the file by GUROBI's experts. It is beacause I have an issue with fix/unfix AMPL command.

I would like to fix the value of the following variables:Y, X_F1, X_F2, ND_NS, Z, U_F1, U_F2, CHARG_F1, CHARG_F2, DEM_NS, DEM_ND.

The results I have obtained for those variables are in a file which I have also uploaded to the private folder.

As the variable Y, X_F1, X_F2, ND_NS, DEM_NS, DEM_ND appear also in the objectif function, I can not treat them as parameters for solving the second part of the model as the second part is made of constraints subject to the same objectif function.

Variables X_F1, and X_F2, appear in results as a lot of data I would like to aks you how I can write them to tell gurobi that want to fix them.

While excepting on your help, please receive my best regards.

Viviane

On Sun, Oct 18, 2020 at 5:40 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Robert,
Well noted. Many thanks!

On Fri, Oct 16, 2020 at 7:46 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
For reading and writing spreadsheet values, see our AMPL Direct Spreadsheet Interface page.

If you are going to solve the two parts in different AMPL sessions, you can write the Xij values from the first part into a spreadsheet, and then read those values from the spreadsheet into parameters for the second part.

If you want to solve the two parts in the same AMPL session, using two solve commands, then you can use a combination of fix/unfix and drop/restore commands to transition from the first part to the second part, or you can define a different AMPL named problem for each part.


--
Robert Fourer
am...@googlegroups.com
On Fri, Oct 16, 2020 at 4:47 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

Many thanks for your help.
I'm going to try to decompose the model in two parts. When I will get results for the first part, I'm going to fix those results for the second part. I'm going to try this, if it doesn't work, then I'm going to drop the file in the link you have provided to ask for support from Gurobi's experts.

To do this, I would like to ask you for example if I have already results for arcs variables Xij from the first part of the model, how can I transmit those fixed results to AMPL using Gurobi, by using a spreadsheet file.

And also I would like to know How can I issue the final result resulting from the solving of the model as form as spreadheet file.

Vivi

unread,
Oct 26, 2020, 1:35:52 PM10/26/20
to am...@googlegroups.com
Dear Mr Robert,

I'm very very grateful for your help. Many many thanks!
I look forward to hearing from you about the reply of Gurobi's experts.
Pease receive my best regards.

Viviane

AMPL Google Group

unread,
Oct 29, 2020, 8:48:33 PM10/29/20
to AMPL Modeling Language
Here is an update:
  • The Gurobi development team looked intensively at the model, and it seems that this is just a really tough model. It has numerical issues, and so it seems there are some computations going on inside the solver that just really take very long. Unfortunately, those computations don't produce any log output.
  • The development team tested this model with their upcoming version 9.1 release and the good news is: It runs much better and faster with the new version.
  • Also they did some additional parameter testing with the current version 9.0 and found that adding "presolve=2 preqlinearize=1" helps a lot. Gurobi gets out of the root relaxation and starts with the root node after about 35 minutes. The first feasible solution is found after about 2 hours. Attached you can find a log file (gurobi.txt) of one of these runs using Gurobi 9.0.3 on an Intel Xeon CPU E3-1240 v3 (3.4 GHz) using 8 threads.
Note that the run shown in gurobi.txt was terminated at the root node, after it had found a feasible solution but while the gap was still large. You might want to let Gurobi run for several hours more just to see whether it would find some better feasible solutions.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Mon, Oct 26, 2020 at 5:35 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Mr Robert,

I'm very very grateful for your help. Many many thanks!
I look forward to hearing from you about the reply of Gurobi's experts.
Pease receive my best regards.

Viviane

On Sun, Oct 25, 2020 at 5:15 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I have sent the experts at Gurobi Optimization an "MPS form" representation of your optimization problem that should enable them to reproduce the errors that we are seeing. (They will not have to look at your actual model.) I will provide an update after I get a reply.

The quadratic terms in your model are of the form "general-variable * binary-variable" which is a special case the can be linearized; see for example Paul Rubin's blog on Binary Variables and Quadratic Terms. These linearizations should be performed automatically by Gurobi, but if necessary -- depending on the reply from the Gurobi experts -- some of them could be done in the AMPL model.


--
Robert Fourer
am...@googlegroups.com
gurobi.txt

Vivi

unread,
Oct 31, 2020, 11:40:54 AM10/31/20
to am...@googlegroups.com
Hi Mr Robert,

Many many thanks for your help. I'm infinitely grateful.
I would like to aks you at which level I must put the "presolve=2 preqlinearize=1" statement in the run file.
I also want to ask you if you know when the last version of Gurobi will be available and if it will be in AMPL version for gaduate students.
Please receive my best regards.

Viviane

AMPL Google Group

unread,
Oct 31, 2020, 3:41:10 PM10/31/20
to AMPL Modeling Language
Hi Viviane,

Add presolve=2 and preqlinearize=1 to the "option" statement that sets your gurobi_options string. For example,

option gurobi_options 'nonconvex=2 outlev=1 timelim=12000 presolve=2 preqlinearize=1';

The latest version of Gurobi (9.0.3) is currently available in all of our downloads.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Sat, Oct 31, 2020 at 3:41 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

Many many thanks for your help. I'm infinitely grateful.
I would like to aks you at which level I must put the "presolve=2 preqlinearize=1" statement in the run file.
I also want to ask you if you know when the last version of Gurobi will be available and if it will be in AMPL version for gaduate students.
Please receive my best regards.

Viviane
On Fri, Oct 30, 2020 at 12:48 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Here is an update:
  • The Gurobi development team looked intensively at the model, and it seems that this is just a really tough model. It has numerical issues, and so it seems there are some computations going on inside the solver that just really take very long. Unfortunately, those computations don't produce any log output.
  • The development team tested this model with their upcoming version 9.1 release and the good news is: It runs much better and faster with the new version.
  • Also they did some additional parameter testing with the current version 9.0 and found that adding "presolve=2 preqlinearize=1" helps a lot. Gurobi gets out of the root relaxation and starts with the root node after about 35 minutes. The first feasible solution is found after about 2 hours. Attached you can find a log file (gurobi.txt) of one of these runs using Gurobi 9.0.3 on an Intel Xeon CPU E3-1240 v3 (3.4 GHz) using 8 threads.
Note that the run shown in gurobi.txt was terminated at the root node, after it had found a feasible solution but while the gap was still large. You might want to let Gurobi run for several hours more just to see whether it would find some better feasible solutions.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Oct 31, 2020, 5:38:43 PM10/31/20
to am...@googlegroups.com
Hi Mr. Robert,

Sorry to ask you repeatedly.
My last question is how to proceed to make AMPL provide a log output like this from Gurobi's experts analyse that you have attached in the previous mail.
Again Many thanks!
Best regards.

Viviane

Vivi

unread,
Nov 1, 2020, 3:31:52 PM11/1/20
to am...@googlegroups.com
Dear Mr Robert,

I wrote the data statement of run file of my model like the following to fix some variables I have had from a previous solving of the model:
reset ;

model Loca_cdu_v6_essai.mod ;

data;
param T0:=0;
param Tmax := 18 ;
param m_F1 := 10 ;
param m_F2 := 40 ;
param CE_F1 := 3.19 ;
param CE_F2 := 0.41 ;
param TP_F1 := 0.66 ;
param TP_F2 := 0.17 ;
param TS_F1 := 0.66 ;
param TS_F2 := 0.17 ;
param TW_max := 2 ;
param M := 10000 ;

data result_Loca_cdu_v6.out;
fix X_F1;
fix X_F2;
fix Y;
fix ND_NS;
fix Z;
fix U_F1;
fix U_F2;
fix CHARG_F1;
fix CHARG_F2;
fix DEM_NS;
fix DEM_ND;

and I have had those statements from AMPL

ampl: include 'C:\Users\AN\Loca_cdu_v6.run';

result_Loca_cdu_v6.out, line 6 (offset 27):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<                   X_F1 X_F2    :=

result_Loca_cdu_v6.out, line 34 (offset 795):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<           ND_NS   Z U_F1 U_F2    :=

result_Loca_cdu_v6.out, line 62 (offset 1635):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<                   CHARG_F1 CHARG_F2    :=

result_Loca_cdu_v6.out, line 86 (offset 2440):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<    DEM_NS DEM_ND    :=
ampl:

I'm writing to ask you what is the right way to write thoses data statement.

Thanks a lot in advance for your help.

Please receive my best regards.

Viviane


Mikhail

unread,
Nov 1, 2020, 10:56:42 PM11/1/20
to AMPL Modeling Language
The fix command must be used in model mode. To do this, fix must be declared in the * .mod file

воскресенье, 1 ноября 2020 г. в 23:31:52 UTC+3, Vivi:

Vivi

unread,
Nov 2, 2020, 8:46:39 AM11/2/20
to am...@googlegroups.com

AMPL Google Group

unread,
Nov 2, 2020, 1:21:33 PM11/2/20
to AMPL Modeling Language
The option outlev=1 in the gurobi_options string requests the log output.

You can put "fix" statements at the end of a dat file, in which case AMPL will switch back to model mode to read and process them. Of you can put your "fix" statements in your run file.

The errors that you are seeing when trying to read file result_Loca_cdu_v6.out all have this form:


expected set, param, [no]defaultsym or end
context: >>> : <<< X_F1 X_F2 :=


It is hard to be sure of the cause, without seeing the file. However, my best guess is that you are missing the keyword "var" at the beginning of each statement. (Normally such statements begin with "param" but when you are reading data into variables, you can use "var" instead.)


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Mon, Nov 2, 2020 at 1:46 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Mr Robert,

On Mon, Nov 2, 2020 at 3:56 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
The fix command must be used in model mode. To do this, fix must be declared in the * .mod file

воскресенье, 1 ноября 2020 г. в 23:31:52 UTC+3, Vivi: . . .

On Sat, Oct 31, 2020 at 9:38 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr. Robert,

Sorry to ask you repeatedly.
My last question is how to proceed to make AMPL provide a log output like this from Gurobi's experts analyse that you have attached in the previous mail.
Again Many thanks!
Best regards.

Viviane

On Sat, Oct 31, 2020 at 7:40 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Hi Viviane,

Add presolve=2 and preqlinearize=1 to the "option" statement that sets your gurobi_options string. For example,

option gurobi_options 'nonconvex=2 outlev=1 timelim=12000 presolve=2 preqlinearize=1';

The latest version of Gurobi (9.0.3) is currently available in all of our downloads.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Nov 2, 2020, 1:49:26 PM11/2/20
to am...@googlegroups.com
Hi Mr Robert,

I don't have data file. I read data from spreadsheet. I have up loaded the model and run file to your private folder (https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv) so that you can see well. Here is again the error message.

result_Loca_cdu_v6.out, line 6 (offset 27):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<                   X_F1 X_F2    :=

result_Loca_cdu_v6.out, line 34 (offset 795):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<           ND_NS   Z U_F1 U_F2    :=

result_Loca_cdu_v6.out, line 62 (offset 1635):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<                   CHARG_F1 CHARG_F2    :=

result_Loca_cdu_v6.out, line 86 (offset 2440):
    expected set, param, [no]defaultsym or end
context:   >>> : <<<    DEM_NS DEM_ND    :=
ampl:

Please receive my best regards,

Viviane

AMPL Google Group

unread,
Nov 2, 2020, 9:22:10 PM11/2/20
to AMPL Modeling Language
In Loca_cdu_8_20_P2.run you have this statement:

data result_Loca_cdu_8_20_P1.out;

This asks AMPL to read file "result_Loca_cdu_8_20_P1.out" as a data file. The error messages are saying that something is wrong in this file:


result_Loca_cdu_v6.out, line 6 (offset 27):
expected set, param, [no]defaultsym or end
context: >>> : <<< X_F1 X_F2 :=


Since you are using the "data" command to read this file, AMPL expects it to be in AMPL text data file format. The error message is saying that it's not in the correct format. I suggested that you need to add the keyword "var" at the beginning of each table in the file; but if you are still uncertain, you can upload the file.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Mon, Nov 2, 2020 at 6:49 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I don't have data file. I read data from spreadsheet. I have up loaded the model and run file to your private folder (https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv) so that you can see well. Here is again the error message.

result_Loca_cdu_v6.out, line 6 (offset 27):
expected set, param, [no]defaultsym or end
context: >>> : <<< X_F1 X_F2 :=

result_Loca_cdu_v6.out, line 34 (offset 795):
expected set, param, [no]defaultsym or end
context: >>> : <<< ND_NS Z U_F1 U_F2 :=

result_Loca_cdu_v6.out, line 62 (offset 1635):
expected set, param, [no]defaultsym or end
context: >>> : <<< CHARG_F1 CHARG_F2 :=

result_Loca_cdu_v6.out, line 86 (offset 2440):
expected set, param, [no]defaultsym or end
context: >>> : <<< DEM_NS DEM_ND :=
ampl:

Please receive my best regards,

Viviane
On Mon, Nov 2, 2020 at 6:21 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The option outlev=1 in the gurobi_options string requests the log output.

You can put "fix" statements at the end of a dat file, in which case AMPL will switch back to model mode to read and process them. Of you can put your "fix" statements in your run file.

The errors that you are seeing when trying to read file result_Loca_cdu_v6.out all have this form:

expected set, param, [no]defaultsym or end
context: >>> : <<< X_F1 X_F2 :=


It is hard to be sure of the cause, without seeing the file. However, my best guess is that you are missing the keyword "var" at the beginning of each statement. (Normally such statements begin with "param" but when you are reading data into variables, you can use "var" instead.)


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Nov 2, 2020, 10:49:22 PM11/2/20
to am...@googlegroups.com
Hi Mr Robert,

I did as you recommanded and it works well.
Many many thanks! Thank you for all the help you give me!

Vivi

unread,
Nov 19, 2020, 1:49:03 AM11/19/20
to AMPL Modeling Language
Dear M. Robert,

I have made some change in my model and have dropped it into your private folder https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv. The folder name is A_V_model_3.

The spreadsheet files include all data, but I have this statement from AMPL, and I don't understand why.

  error processing objective Cout_Total:
    invalid subscript D_LINKS_F2['S1','Missing']


Please can you help me?

Kinds regards.

Vivi

unread,
Nov 19, 2020, 2:10:04 AM11/19/20
to AMPL Modeling Language
Dear M. Robert,

I have made some change in my model and have dropped it into your private folder https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv. The folder name is A_V_model_3. Please consider only the second folder I have up loaded.

The spreadsheet files include all data, but I have this statement from AMPL, and I don't understand why.

  error processing objective Cout_Total:
    invalid subscript D_LINKS_F2['S1','Missing']


Please can you help me?

Kinds regards.

AMPL Google Group

unread,
Nov 19, 2020, 7:15:14 PM11/19/20
to AMPL Modeling Language
Your table NC_tab on sheet "nc" has an extra line:

cc4c0626b0bb1c1225e89de1a86bb5be.png

Line 22 contains a value for DEM_NC, but has a blank where there should be a corresponding member of set NC. In this situation, the AMPL spreadsheet interface gives the name "Missing" to the to the blank member of NC. Thus your set NC has an extra member named "Missing" and this eventually results in an "invalid subscript" error when AMPL tries to process your objective function. Delete the "930" in the extra line, and the error will go away.

In a future release, we may fix the spreadsheet interface so that it instead signals an error when there is a blank set member in a table.


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Thu, Nov 19, 2020 at 7:10 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear M. Robert,

I have made some change in my model and have dropped it into your private folder https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv. The folder name is A_V_model_3. Please consider only the second folder I have up loaded.

The spreadsheet files include all data, but I have this statement from AMPL, and I don't understand why.

error processing objective Cout_Total:
invalid subscript D_LINKS_F2['S1','Missing']

Please can you help me?

Kinds regards.

On Thu, Nov 19, 2020 at 6:49 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear M. Robert,

I have made some change in my model and have dropped it into your private folder https://www.dropbox.com/request/Yy6cQ0RGwqCsBy9Kr7vv. The folder name is A_V_model_3.

The spreadsheet files include all data, but I have this statement from AMPL, and I don't understand why.

error processing objective Cout_Total:
invalid subscript D_LINKS_F2['S1','Missing']

Please can you help me?

Kinds regards.

On Tue, Nov 3, 2020 at 3:49 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I did as you recommanded and it works well.
Many many thanks! Thank you for all the help you give me!

On Tue, Nov 3, 2020 at 2:21 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
In Loca_cdu_8_20_P2.run you have this statement:

data result_Loca_cdu_8_20_P1.out;

This asks AMPL to read file "result_Loca_cdu_8_20_P1.out" as a data file. The error messages are saying that something is wrong in this file:

result_Loca_cdu_v6.out, line 6 (offset 27):
expected set, param, [no]defaultsym or end
context: >>> : <<< X_F1 X_F2 :=


Since you are using the "data" command to read this file, AMPL expects it to be in AMPL text data file format. The error message is saying that it's not in the correct format. I suggested that you need to add the keyword "var" at the beginning of each table in the file; but if you are still uncertain, you can upload the file.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Nov 22, 2020, 8:36:18 PM11/22/20
to AMPL Modeling Language
Big thank you Robert for your precious help!

Vivi

unread,
Nov 24, 2020, 12:44:50 AM11/24/20
to AMPL Modeling Language
Hi Mr Robert,

I have this statement when solving my model :

Setting $presolve_eps >= 1.89e-12 might help.

I'am writnig to you to have the meaning of that.

Best Regards,

Viviane

Vivi

unread,
Nov 24, 2020, 8:36:21 AM11/24/20
to AMPL Modeling Language
Hi Mr Robert,

I have this statement when solving my model :

ampl: include 'C:\Users\A\Loca_cdu_4_20_p2.run';
presolve, variable TW_F1['S4']:
    impossible deduced bounds: lower = 0.621, upper = 0.621;
    difference = 1.57163e-12
presolve, variable TW_F1['S3']:
    impossible deduced bounds: lower = 0.935, upper = 0.935;
    difference = 2.61946e-12

Setting $presolve_eps >= 1.89e-12 might help.
ampl:

I'am writnig to you to have the meaning of that.

Best Regards,

Viviane

AMPL Google Group

unread,
Nov 25, 2020, 10:47:30 AM11/25/20
to AMPL Modeling Language
The "impossible deduced bounds" message means that AMPL's presolve algorithms have computed a lower bound and an upper bound on some variable, and the lower bound is greater than the upper bound. Thus presolve has proved that your problem has no feasible solution, without having to send the problem to the solver.

The "difference = . . ." message shows how much the lower bound is greater than the upper bound. In your example, this difference is extremely small: on the order of 10^-12. Most solvers would ignore such a small difference, so you may want to tell presolve to ignore this difference, and to send the problem to the solver. You can do this by setting AMPL option presolve_eps to some small positive value; differences of less than presolve_eps between the lower and upper bound will then be ignored.

The message "Setting $presolve_eps >= 1.89e-12 might help" suggests how you might set presolve_eps in this situation. Since the largest "difference = . . ." value reported by presolve is 2.61946e-12, you might try "option presolve_eps 1e-11;".


--
Robert Fourer
am...@googlegroups.com
{#HS:1299492081-89616#}
On Tue, Nov 24, 2020 at 1:36 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I have this statement when solving my model :

ampl: include 'C:\Users\A\Loca_cdu_4_20_p2.run';
presolve, variable TW_F1['S4']:
impossible deduced bounds: lower = 0.621, upper = 0.621;
difference = 1.57163e-12
presolve, variable TW_F1['S3']:
impossible deduced bounds: lower = 0.935, upper = 0.935;
difference = 2.61946e-12
Setting $presolve_eps >= 1.89e-12 might help.
ampl:

I'am writnig to you to have the meaning of that.

Best Regards,

Viviane
On Tue, Nov 24, 2020 at 5:45 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Mr Robert,

I have this statement when solving my model :

Setting $presolve_eps >= 1.89e-12 might help.

I'am writnig to you to have the meaning of that.

Best Regards,

Viviane
On Mon, Nov 23, 2020 at 1:36 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Big thank you Robert for your precious help!

On Fri, Nov 20, 2020 at 12:14 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Your table NC_tab on sheet "nc" has an extra line:

cc4c0626b0bb1c1225e89de1a86bb5be.png

Line 22 contains a value for DEM_NC, but has a blank where there should be a corresponding member of set NC. In this situation, the AMPL spreadsheet interface gives the name "Missing" to the to the blank member of NC. Thus your set NC has an extra member named "Missing" and this eventually results in an "invalid subscript" error when AMPL tries to process your objective function. Delete the "930" in the extra line, and the error will go away.

In a future release, we may fix the spreadsheet interface so that it instead signals an error when there is a blank set member in a table.


--
Robert Fourer
am...@googlegroups.com

Vivi

unread,
Nov 25, 2020, 1:15:39 PM11/25/20
to AMPL Modeling Language
Hi Mr Robert,

Many many thanks!!!
Reply all
Reply to author
Forward
0 new messages