Returning an IIS of 9 constraints

361 views
Skip to first unread message

John Lotus

unread,
Feb 18, 2021, 5:28:51 AM2/18/21
to AMPL Modeling Language
Goodmorning everyone, i have an issue in AMPL (i use as a solver Gurobi), below the error:

Gurobi: iisfind=1
Gurobi: infeasible
Returning an IIS of 9 constraints
No primal variables returned

I know for sure that the error is generated by these two constraints:

R = 8
C = 6
bin: binary variable
V = 999999
subject to check_low {r1 in R, r2 in R, r3 in R, c1 in C, c2 in C, c3 in C, c4 in C: r1 != r2 and r1!=r3 and r2!=r3 and c1!=c2}: mat[r1,c1] <= (mat[r2,c2] - 1) + (1 - bin[r3,c3,c4])*V;

subject to check_up {r1 in R, r2 in R, r3 in R, c1 in C, c2 in C, c3 in C, c4 in C: r1 != r2 and r1!=r3 and r2!=r3 and c1!=c2}: mat[r1,c1] >= (mat[r2,c2] + 1) - (bin[r3,c3,c4])*V;

the goal of these two constraints is to check that all values are different, but I don't understand what's wrong with it.

thank you so much for your time,

John Lotus

AMPL Google Group

unread,
Feb 18, 2021, 2:25:42 PM2/18/21
to AMPL Modeling Language
Gurobi reports that it has found an irreducible infeasible subset (IIS) of only 9 constraints. To see which constraints those are, use this AMPL command:

display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

You can also show the specific constraints that AMPL generated, rather than just the names, with this AMPL command:

expand {i in 1.._ncons: _con[i].iis != "non"} _con[i];

Your optimization problem has many check_low and check_up constraints, but the IIS will contain just 9 constraints that cannot all be satisfied, and you can focus on those 9 constraints when looking for the cause of the infeasibility.


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
--
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/afa111d4-d950-4f12-84f5-701d9bc2ebf4n%40googlegroups.com.

John Lotus

unread,
Feb 18, 2021, 4:41:56 PM2/18/21
to AMPL Modeling Language
Thanks a lot for the answer, 
i tried the command but it prints me more than 23000 constraints (I just copied and pasted the suggested command), I haven't tried the second command yet. 

below the .RUN file:

reset;
option solver gurobi;
option gurobi_options 'iisfind=1';
model exercise.mod;
data exercise.dat;
solve;
display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];
expand {i in 1.._ncons: _con[i].iis != "non"} _con[i];
display exercise;

what am I doing wrong?

Thank you so much for your time and effort,

John Lotus

AMPL Google Group

unread,
Feb 19, 2021, 1:45:42 PM2/19/21
to AMPL Modeling Language
I tested out your run file (but on a different model) and the results were correct. To get more help, I suggest that you copy all of the output from your solve, and at least the first 10 lines of the output from the following display command, and paste that all into an email back to this forum.


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Thu, Feb 18, 2021 at 9:42 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thanks a lot for the answer,
i tried the command but it prints me more than 23000 constraints (I just copied and pasted the suggested command), I haven't tried the second command yet.

below the .RUN file:

reset;
option solver gurobi;
option gurobi_options 'iisfind=1';
model exercise.mod;
data exercise.dat;
solve;
display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];
expand {i in 1.._ncons: _con[i].iis != "non"} _con[i];
display exercise;

what am I doing wrong?

Thank you so much for your time and effort,

John Lotus

On Thu, Feb 18, 2021 at 7:25 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Gurobi reports that it has found an irreducible infeasible subset (IIS) of only 9 constraints. To see which constraints those are, use this AMPL command:

display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

You can also show the specific constraints that AMPL generated, rather than just the names, with this AMPL command:

expand {i in 1.._ncons: _con[i].iis != "non"} _con[i];

Your optimization problem has many check_low and check_up constraints, but the IIS will contain just 9 constraints that cannot all be satisfied, and you can focus on those 9 constraints when looking for the cause of the infeasibility.


--
Robert Fourer
am...@googlegroups.com
On Thu, Feb 18, 2021 at 10:29 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Good morning everyone, i have an issue in AMPL (i use as a solver Gurobi), below the error:
Message has been deleted

John Lotus

unread,
Feb 22, 2021, 10:26:56 AM2/22/21
to AMPL Modeling Language
First of all, thank you so much for checking my code.

I would like to copy all the code but unfortunately i can copy only the last 1000 line, I will copy the last 20 lines since the only difference with the others are the indexes:

46061 ' check_up[6,5,4,4,2,4,1]'     0
46062 'check_up[6,5,4,4,2,4,2]'     0
46063 'check_up[6,5,4,4,2,4,3]'     0
46064 'check_up[6,5,4,4,2,4,4]'     0
46065 'check_up[6,5,4,4,3,1,1]'     0
46066 'check_up[6,5,4,4,3,1,2]'     0
46067 'check_up[6,5,4,4,3,1,3]'     0
46068 'check_up[6,5,4,4,3,1,4]'     0
46069 'check_up[6,5,4,4,3,2,1]'     0
46070 'check_up[6,5,4,4,3,2,2]'     0
46071 'check_up[6,5,4,4,3,2,3]'     0
46072 ' check_up[6,5,4,4,3,2,4]'     0
46073 ' check_up[6,5,4,4,3,3,1]'     0
46074 ' check_up[6,5,4,4,3,3,2]'     0
46075 ' check_up[6,5,4,4,3,3,3]'     0
46076 ' check_up[6,5,4,4,3,3,4]'     0
46077 ' check_up[6,5,4,4,3,4,1]'     0
46078 ' check_up[6,5,4,4,3,4,2]'     0
46079 'check_up[6,5,4,4,3,4,3]'     0
46080 'check_up[6,5,4,4,3,4,4]'     0
;

these are the last lines, my doubt is: does this command work on all versions of gurobi?

I renew my thanks,

John Lotus

AMPL Google Group

unread,
Feb 24, 2021, 1:47:33 PM2/24/21
to AMPL Modeling Language
Unfortunately, the important information is at the beginning of the listing. Also the output of the proper display statement,


display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

does not produce a "0" at the end of each line of output. So I must ask you to do several more things:
  • Run the test again, but with exactly the display statement shown above. If the output is different and not so long, then copy the entire AMPL session into your reply -- including what you typed and all the output that AMPL generated.
  • If you still get very long output, again copy the last 10 lines into your reply. Then run the test again, but without the "display" statement; and copy the entire AMPL session into your reply.
  • If you used a command file (or "run file") then also attach that file, or copy its contents into your reply


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Fri, Feb 19, 2021 at 6:45 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I tested out your run file (but on a different model) and the results were correct. To get more help, I suggest that you copy all of the output from your solve, and at least the first 10 lines of the output from the following display command, and paste that all into an email back to this forum.


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

John Lotus

unread,
Mar 1, 2021, 4:11:14 PM3/1/21
to AMPL Modeling Language
I followed your instructions, I state that I have added constraints to decrease the number of iterations performed.

Here the first test (i still have a long output):

994 'check_up[6,5,4,1,4,3,2]'     0
995 'check_up[6,5,4,2,1,4,3]'     0
996 'check_up[6,5,4,2,3,4,1]'     0
997 'check_up[6,5,4,2,4,1,3]'     0
998 'check_up[6,5,4,2,4,3,1]'     0
999 'check_up[6,5,4,3,1,4,2]'     0
1000 ' check_up[6,5,4,3,2,4,1]'     0
1001 ' check_up[6,5,4,3,4,1,2]'     0
1002 ' check_up[6,5,4,3,4,2,1]'     0
1003 ' check_up[6,5,4,4,1,2,3]'     0
1004 ' check_up[6,5,4,4,1,3,2]'     0

Here the second test without  the "display" statement:

Gurobi: iisfind = 1
Gurobi: infeasible
Returning an IIS of 21 constraints.
200 simplex interations
No primal variables returned.

i think the problem is the very dated version of my gurobi, i will look for a way to solve the constraints not respected.

Thanks so much for your help

John Lotus

AMPL Google Group

unread,
Mar 2, 2021, 3:09:35 PM3/2/21
to AMPL Modeling Language
Please check your "display" statement. Gurobi reports "Returning an IIS of 21 constraints" so the statement


display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

should produce 21 lines out output. Also the lines should not end with "0".

Also when you request help with a run, when possible you should show all of the output from your session. The best way to do this is to copy the contents of your console/terminal window and paste it into your email.


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Mon, Mar 1, 2021 at 9:11 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
I followed your instructions, I state that I have added constraints to decrease the number of iterations performed.

Here the first test (i still have a long output):

994 'check_up[6,5,4,1,4,3,2]' 0
995 'check_up[6,5,4,2,1,4,3]' 0
996 'check_up[6,5,4,2,3,4,1]' 0
997 'check_up[6,5,4,2,4,1,3]' 0
998 'check_up[6,5,4,2,4,3,1]' 0
999 'check_up[6,5,4,3,1,4,2]' 0
1000 ' check_up[6,5,4,3,2,4,1]' 0
1001 ' check_up[6,5,4,3,4,1,2]' 0
1002 ' check_up[6,5,4,3,4,2,1]' 0
1003 ' check_up[6,5,4,4,1,2,3]' 0
1004 ' check_up[6,5,4,4,1,3,2]' 0

Here the second test without the "display" statement:

Gurobi: iisfind = 1
Gurobi: infeasible
Returning an IIS of 21 constraints.
200 simplex interations
No primal variables returned.

i think the problem is the very dated version of my gurobi, i will look for a way to solve the constraints not respected.

Thanks so much for your help

John Lotus

On Wed, Feb 24, 2021 at 6:47 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Unfortunately, the important information is at the beginning of the listing. Also the output of the proper display statement,

display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

does not produce a "0" at the end of each line of output. So I must ask you to do several more things:
  • Run the test again, but with exactly the display statement shown above. If the output is different and not so long, then copy the entire AMPL session into your reply -- including what you typed and all the output that AMPL generated.
  • If you still get very long output, again copy the last 10 lines into your reply. Then run the test again, but without the "display" statement; and copy the entire AMPL session into your reply.
  • If you used a command file (or "run file") then also attach that file, or copy its contents into your reply


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

John Lotus

unread,
Mar 9, 2021, 11:34:36 AM3/9/21
to AMPL Modeling Language
Hi, I apologize for the late reply but in the end I was able to resolve the error given by the display.
I take this opportunity to ask one last doubt on the logical variables, I tried to make this inequality:

subject to verification {i in 1 .. 12}: vect[i] <= 1000 + not(bin[i])*3000;

but this expression gives me the following error:

exercise.mod, line 30 (offset 328):
                syntax error
context: subject to verification {i in 1 .. 12}: vect[i]  >>> <= <<< 100 + not(bin[i])*300;

what did I do wrong?

Thanks so much for your time and help, it is truly appreciated

John Lotus

AMPL Google Group

unread,
Mar 9, 2021, 12:30:41 PM3/9/21
to AMPL Modeling Language
The cause of the error may relate to how "vect" is defined. Can you post the model file, at least up to the constraint statement for "verification"?


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Tue, Mar 9, 2021 at 4:34 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi, I apologize for the late reply but in the end I was able to resolve the error given by the display. I take this opportunity to ask one last doubt on the logical variables, I tried to make this inequality:

subject to verification {i in 1 .. 12}: vect[i] <= 1000 + not(bin[i])*3000;

but this expression gives me the following error:

exercise.mod, line 30 (offset 328):
syntax error
context: subject to verification {i in 1 .. 12}: vect[i] >>> <= <<< 100 + not(bin[i])*300;

what did I do wrong?

Thanks so much for your time and help, it is truly appreciated

John Lotus

On Tue, Mar 2, 2021 at 8:09 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Please check your "display" statement. Gurobi reports "Returning an IIS of 21 constraints" so the statement

display {i in 1.._ncons: _con[i].iis != "non"} _conname[i];

should produce 21 lines out output. Also the lines should not end with "0".

Also when you request help with a run, when possible you should show all of the output from your session. The best way to do this is to copy the contents of your console/terminal window and paste it into your email.


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

John Lotus

unread,
Mar 9, 2021, 12:41:30 PM3/9/21
to AMPL Modeling Language
Yes, here the code:

param elements{1..12,1..10}; //it is an array with preloaded values

constraint:

set vect{i in 1..12} = {j in 1..10: elements[i,j] = min {ii in 1..12} elements[ii,j]}; 
subject to verification {i in 1 .. 12}: vect[i] <= 1000 + not(bin[i])*3000;

Do you need more line ?
Message has been deleted
Message has been deleted

AMPL Google Group

unread,
Mar 10, 2021, 2:52:35 PM3/10/21
to AMPL Modeling Language
It seems that your latest version is:

set vect {i in 1..12} = {min {j in 1..10} elements[i,j]};
...
subject to verification {i in 1..12}: vect[i] <= 100 + not(bin[i])*300;


But vect[i] is a set, so a constraint cannot say that it is <= something. Instead, you can define vect as a param:

param vect {i in 1..12} = min {j in 1..10} elements[i,j];

Then "vect[i] <= . . ." will not be flagged as a syntax error.

Also, AMPL does not have a function named "not" so to avoid another syntax error, you will need to rewrite "not(bin[i])". If bin[i] is a binary variable as you previously stated, then you can use "1 - bin[i]".


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Wed, Mar 10, 2021 at 11:17 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
After running a few more test i'm sure that the line:

set vect{i in 1..12} = {min {j in 1..12} elements[i,j]}; //i've modified it because the previous one was wrong

is causing the syntax error, but i don't understand why.
do I have to write it somewhere else in the file?

Thank you for your help,

John Lotus

On Wed, Mar 10, 2021 at 10:46 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
After running some tests I found that the following line does not give me the minimum of each line:


set vect{i in 1..12} = {j in 1..10: elements[i,j] = min {ii in 1..12} elements[ii,j]};

elements is a matrix defined in this way:

param elements :=
1 2 3 ... 10
1 3 6 8 0
2
3
4
5
...
12 12 4 5 ... 8;

what i want to find is the minimum of each line, how can i do?
P.s. the previous problem I think depends on the previous line.

Thank you for your effort

John Lotus

On Tue, Mar 9, 2021 at 5:41 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Yes, here the code:

param elements{1..12,1..10}; //it is an array with preloaded values

constraint:

set vect{i in 1..12} = {j in 1..10: elements[i,j] = min {ii in 1..12} elements[ii,j]};
subject to verification {i in 1 .. 12}: vect <= 1000 + not(bin)*3000;


Do you need more line ?
On Tue, Mar 9, 2021 at 5:30 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The cause of the error may relate to how "vect" is defined. Can you post the model file, at least up to the constraint statement for "verification"?


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

John Lotus

unread,
Mar 10, 2021, 4:51:15 PM3/10/21
to AMPL Modeling Language
thank you it works! 

I would like to express one last doubt (i hope it will be the last one), i've this nonquadratic constraint:

var a{1 .. 4}
subject to control: a[1]*a[2]*a[3]*a[4] + a[1] = 1;

from what I have studied I know that I can rewrite a[1]*a[2]*a[3]*a[4]  in the following way:

subject to constraint1: a[1] >= 1 - d
sebject to constraint2: a[2] >= 1 - d 
subject to constraint3: a[3] >= 1 - d
subject to constraint4: a[4] >= 1 - d 

But how can i implement the +a[1]  (it should be an 'OR') ?

thank you so much for your time and patience,

John Lotus

AMPL Google Group

unread,
Mar 11, 2021, 12:51:16 PM3/11/21
to AMPL Modeling Language
This reformulation does not look familiar to me. It would help if you could give the complete AMPL definition for d, and also the complete AMPL definition for a (showing its bounds and also "integer" or "binary" if appropriate).


--
Robert Fourer
am...@googlegroups.com
{#HS:1429477755-100993#}
On Wed, Mar 10, 2021 at 9:51 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
thank you it works!

I would like to express one last doubt (i hope it will be the last one), i've this nonquadratic constraint:

var a{1 .. 4}
subject to control: a[1]*a[2]*a[3]*a[4] + a[1] = 1;

from what I have studied I know that I can rewrite a[1]*a[2]*a[3]*a[4] in the following way:

subject to constraint1: a[1] >= 1 - d
sebject to constraint2: a[2] >= 1 - d

subject to constraint3: a[3] >= 1 - d
subject to constraint4: a[4] >= 1 - d

But how can i implement the +a[1] (it should be an 'OR') ?

thank you so much for your time and patience,

John Lotus

On Wed, Mar 10, 2021 at 7:52 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It seems that your latest version is:

set vect {i in 1..12} = {min {j in 1..10} elements[i,j]};
...
subject to verification {i in 1..12}: vect[i] <= 100 + not(bin[i])*300;


But vect[i] is a set, so a constraint cannot say that it is <= something. Instead, you can define vect as a param:

param vect {i in 1..12} = min {j in 1..10} elements[i,j];

Then "vect[i] <= . . ." will not be flagged as a syntax error.

Also, AMPL does not have a function named "not" so to avoid another syntax error, you will need to rewrite "not(bin[i])". If bin[i] is a binary variable as you previously stated, then you can use "1 - bin[i]".


--
Robert Fourer
am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages