AMPL Displaying variables which are equal to 1

11 views
Skip to first unread message

chaitany...@gmail.com

unread,
Nov 29, 2015, 3:25:29 PM11/29/15
to AMPL Modeling Language
Hello,

I have a small Binary optimization problem(3600+ variable) in AMPL and after I'd solved that I would like to display only those variables which are 1. I tried using for and if-then but I always get a syntax error. Can Anyone help me with writing an AMPL script which will help me display only 1s?


Victor Zverovich

unread,
Nov 30, 2015, 6:48:57 PM11/30/15
to am...@googlegroups.com
You can do this with a simple indexing expression such as

  display {i in I: x[i] = 1} x[i];

where I is an indexing set of variable x.

HTH,
Victor

On Sun, Nov 29, 2015 at 12:25 PM <chaitany...@gmail.com> wrote:
Hello,

I have a small Binary optimization problem(3600+ variable) in AMPL and after I'd solved that I would like to display only those variables which are 1. I tried using for and if-then but I always get a syntax error. Can Anyone help me with writing an AMPL script which will help me display only 1s?


--
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 http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages