Logical operators

407 views
Skip to first unread message

Dilip Kothari

unread,
Apr 8, 2007, 4:30:08 AM4/8/07
to am...@googlegroups.com
Hi
Is AMPL permit the use of logical operators.
e.g I wish to write
zn[i,j] = z[i,j] OR y[i,j]
where zn,z and y are variables. i and j are index over sets
I and J respectively.
Thanks,
DK



____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html

Robert Fourer

unread,
Apr 11, 2007, 4:03:02 PM4/11/07
to am...@googlegroups.com, Dilip Kothari
AMPL does allow constraints that use logical operators like "or" (not "OR"),
but currently none of the AMPL-solver interfaces are set up to use such
constraints.

Bob Fourer
4...@ampl.com

Jen T

unread,
Nov 15, 2009, 7:04:11 PM11/15/09
to am...@googlegroups.com

I'm new to AMPL, so try to forgive me if this question is posed elsewhere,
or if there is an obvious solution.

As the solvers don't support logical operators, is there an alternative way
to
encode a constraint of the following form...

subject to constraintName : c1 or c2;

... where c1 and c2 are simple non-strict inequalities?
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "AMPL Modeling Language" group.
> To post to this group, send email to am...@googlegroups.com
> To unsubscribe from this group, send email to
> ampl-uns...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ampl?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>
>

--
View this message in context: http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26365085.html
Sent from the AMPL mailing list archive at Nabble.com.

Robert Fourer

unread,
Nov 17, 2009, 4:14:07 PM11/17/09
to am...@googlegroups.com, Jen T

To express such a "disjunctive" constraint of this kind for current solvers,
you need to define a zero-one (or "binary") variable and to create two
constraints. The first constraint is equivalent to c1 when the binary
variable is 1, but is trivially satisfied when the binary variable is 0; the
second constraint is equivalent to c2 when the binary variable is 0, but is
trivially satisfied when the binary variable is 1.

The details depend on the specifics of your constraints. But as a simple
example if you want to specify

param a >= 0;
param b >= 0;

var x >= 0;
var y >= 0;

subj to eitheror: x >= a or y >= b;

then you can write

var u binary;

subj to eitherx: x >= a * u;
subj to eithery: y >= b * (1-u);

For other kinds of inequalities the formulation is a little different, but
it's not hard to find once you appreciate the principle involved.
> --
>
> You received this message because you are subscribed to the Google Groups
> "AMPL Modeling Language" group.
> To post to this group, send email to am...@googlegroups.com.
> To unsubscribe from this group, send email to
> ampl+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ampl?hl=.
>


Jen T

unread,
Nov 17, 2009, 7:00:16 PM11/17/09
to am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages