If-then constraint

32 views
Skip to first unread message

Andres Castillo

unread,
May 19, 2017, 7:00:14 PM5/19/17
to AMPL Modeling Language
Hi all, 

I have been trying to work on an if-then statement for my model but so far I cannot do it. 

Basically, what I want to do is the following:

IF the presolve of contraint1 is different than 0 THEN do not execute constraint2, constraint3... constraint10. But IF it is equal to 0 THEN execute those constraints.

What I was thinking is: 

if constraint1{i in S}: w[j] = sum{r in D, q in WR[r]} ZWR[j,r,q] * g[r,q] <> 0 then constraint2, constraint3... constraint10 (I do nothing, I do not know how to describe it) 

Thanks in advance.

Robert Fourer

unread,
May 21, 2017, 7:20:42 PM5/21/17
to am...@googlegroups.com
Can you explain what you mean by "the presolve of constraint1"? This is not a familiar expression. However in general you can selectively remove constraints from the problem by writing a statement of the following form:

if <<some condition>> then {
drop constraint2;
drop constraint3;
...
}

Bob Fourer
am...@googlegroups.com

=======

andr...@ualberta.ca

unread,
May 24, 2017, 3:29:05 PM5/24/17
to AMPL Modeling Language, 4...@ampl.com
Thank you Bob for your respond. 

I will explain myself a little bit more. I have a model that ran perfectly for some scenarios but not for others. This is because one important constraint cannot be satisfied and the problem is unfeasible. Let us call this constraint "contraint10" therefore a message appears saying that presolve: constraint10['Z'] cannot hold. This basically happened because if constraint1, constraint2, and constraint3 want to be satisfied then it cannot satisfy constraint10 at the same time. 

What I am trying to build is an if-then constraint that says that whenever constraint10['Z'] can't hold then do not execute constraint1, constraint2, and constraint3. But I need to execute the model first because I don't know which is the want that cannot hold (constraint10 makes a lot of iterations i.e: { constraint10['A'], constraint10['B'], constraint10['C']... constraint10['Z'] }

Thanks in advance Bob

Robert Fourer

unread,
May 30, 2017, 12:06:19 AM5/30/17
to am...@googlegroups.com
There is no way to test in AMPL whether presolve found that "constraint10" could not hold. Maybe we should introduce a new value for constraint10.astatus that would indicate that the constraint was found to be infeasible, but that will require some study to see whether it can be done reliably.

Instead you could figure out why constraint10['Z'] cannot be satisfied, and then test for that. As a very simple example, if it can't be satisfied because supply is less than demand, then that is something you could test by saying

if supply < demand then {
drop constraint1;
drop constraint2;
drop constraint3;
}

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages