[AMPL 2138] Question about display command

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 2138] Question about display command

jeffhgoldsmith@gmail.com

I wrote a very basic BIP matching program, and I have a question about
an output I am receiving with the display command.  My program matches
a pair (i and j) together in one constraint, and then restricts that
pair from being matched together in another period (k).  Solving the
problem using cplex provides a feasible solution, and if I type:

display x;

a matrix is printed out just like it should be, filled with zeros and
ones.  If I type:

display restriction_constraint;

a matrix full of zeros is printed out, which is unexpected.  This
constraint takes the form of x[i,j,k] <= 1 for all k | i != j.  The
first expanded line of my constraint is:

expand restriction_constraint[1,2];
x[1,2,1] + x[1,2,2] + x[1,2,3] <=  1

typing display restriction_constraint[1,2]; yields
restriction_constraint = 0;

however typing display x[1,2,1] , x[1,2,2] , x[1,2,3]; yields
x[1,2,1] = 0
x[1,2,2] = 1
x[1,2,3] = 0

Shouldn't restriction_constraint[1,2]=1?  Why does the display command
report zero?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

[AMPL 2139] Re: Question about display command

Robert Fourer-2


The command "display restriction_constraint" is equivalent to "display
restriction_constraint.dual" -- it displays the dual values corresponding to
the restriction_constraint constraints.  If your variables x are defined as
binary (that is, zero-one) then CPLEX is solving an integer program and no
dual values are determined; dual values are not defined for an integer
program, at least not by CPLEX.  So when you display the dual values you get
all zeros.

I think what you're looking for is "display restriction_constraint.body",
which displays the sum of all the variables in the constraint (after they
are moved to the left of the comparison operator, if necessary).

Bob Fourer
[hidden email]


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Friday, December 26, 2008 2:22 AM
> To: AMPL Modeling Language
> Subject: [AMPL 2138] Question about display command
>
>
> I wrote a very basic BIP matching program, and I have a question about
> an output I am receiving with the display command.  My program matches
> a pair (i and j) together in one constraint, and then restricts that
> pair from being matched together in another period (k).  Solving the
> problem using cplex provides a feasible solution, and if I type:
>
> display x;
>
> a matrix is printed out just like it should be, filled with zeros and
> ones.  If I type:
>
> display restriction_constraint;
>
> a matrix full of zeros is printed out, which is unexpected.  This
> constraint takes the form of x[i,j,k] <= 1 for all k | i != j.  The
> first expanded line of my constraint is:
>
> expand restriction_constraint[1,2];
> x[1,2,1] + x[1,2,2] + x[1,2,3] <=  1
>
> typing display restriction_constraint[1,2]; yields
> restriction_constraint = 0;
>
> however typing display x[1,2,1] , x[1,2,2] , x[1,2,3]; yields
> x[1,2,1] = 0
> x[1,2,2] = 1
> x[1,2,3] = 0
>
> Shouldn't restriction_constraint[1,2]=1?  Why does the display command
> report zero?
>
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

[AMPL 2140] Re: Question about display command

jeffhgoldsmith@gmail.com

Thank you for your help!  The .body suffix is exactly what I was
looking for!

On Dec 27, 10:22 am, "Robert Fourer" <[hidden email]> wrote:

> The command "display restriction_constraint" is equivalent to "display
> restriction_constraint.dual" -- it displays the dual values corresponding to
> the restriction_constraint constraints.  If your variables x are defined as
> binary (that is, zero-one) then CPLEX is solving an integer program and no
> dual values are determined; dual values are not defined for an integer
> program, at least not by CPLEX.  So when you display the dual values you get
> all zeros.
>
> I think what you're looking for is "display restriction_constraint.body",
> which displays the sum of all the variables in the constraint (after they
> are moved to the left of the comparison operator, if necessary).
>
> Bob Fourer
> [hidden email]
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of
> > [hidden email]
> > Sent: Friday, December 26, 2008 2:22 AM
> > To: AMPL Modeling Language
> > Subject: [AMPL 2138] Question about display command
>
> > I wrote a very basic BIP matching program, and I have a question about
> > an output I am receiving with the display command.  My program matches
> > a pair (i and j) together in one constraint, and then restricts that
> > pair from being matched together in another period (k).  Solving the
> > problem using cplex provides a feasible solution, and if I type:
>
> > display x;
>
> > a matrix is printed out just like it should be, filled with zeros and
> > ones.  If I type:
>
> > display restriction_constraint;
>
> > a matrix full of zeros is printed out, which is unexpected.  This
> > constraint takes the form of x[i,j,k] <= 1 for all k | i != j.  The
> > first expanded line of my constraint is:
>
> > expand restriction_constraint[1,2];
> > x[1,2,1] + x[1,2,2] + x[1,2,3] <=  1
>
> > typing display restriction_constraint[1,2]; yields
> > restriction_constraint = 0;
>
> > however typing display x[1,2,1] , x[1,2,2] , x[1,2,3]; yields
> > x[1,2,1] = 0
> > x[1,2,2] = 1
> > x[1,2,3] = 0
>
> > Shouldn't restriction_constraint[1,2]=1?  Why does the display command
> > report zero?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---