[AMPL 2607] Two vars in one constraint

View: New views
3 Messages — Rating Filter:   Alert me  

[AMPL 2607] Two vars in one constraint

by lukyluke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello everybody,

I tried to add a constraint into my model, but I get some errors from
cplex and  minos.

My first version of this constraint was:

sets: K, R, O, L
var: Ho, Ca
param: r, o

subject to answer_all {k in K}:
        sum{(f,k) in R} (if (f,k) in O then 0 else  r[f,k]) = sum{(f,t) in L,
(t,k) in O} o[t,k] * Ho[f,t,k];

This works well, but when I change it to:

subject to answer_all_requests {k in K}:
        sum{(f,k) in R} (if (f,k) in O or Ca[f,k] = 1 then 0 else r[f,k]) =
sum{(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k];

I get this errors:
###MINOS##
MINOS 5.51: ignoring integrality of 6 variables
MINOS 5.51: optimal solution found.
1 iterations, objective 12
Nonlin evals: constrs = 3, Jac = 2.

##CPLEX###
CPLEX 11.2.0: Constraint _scon[1] is not convex quadratic since it is
an equality constraint.

Thanks,
eL Jey

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


[AMPL 2610] Re: Two vars in one constraint

by Robert Fourer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



MINOS does not recognize integer variables.  Also putting "Ca[f,k] = 1" in
the "if" condition makes the constraint nonlinear, and CPLEX does not handle
most linear constraints (the exception being certain convex quadratic ones
mentioned in its error message).

If Ca is a zero-one variable then you could try the following, though:

   subject to answer_all_requests {k in K}:
      sum {(f,k) in R diff O} (1 - Ca[f,k]) * r[f,k] =
      sum {(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k];

In general when modeling with integer variables and solving with CPLEX you
need to use a trick of some kind to make your constraint linear in the
variables.

Bob Fourer
4er@...


> -----Original Message-----
> From: ampl@... [mailto:ampl@...]
> On Behalf Of aL Jey [lukasbanach@...]
> Sent: Monday, June 22, 2009 9:20 AM
> To: AMPL Modeling Language
> Subject: [AMPL 2607] Two vars in one constraint
>
>
> Hello everybody,
>
> I tried to add a constraint into my model, but I get some errors from
> cplex and  minos.
>
> My first version of this constraint was:
>
> sets: K, R, O, L
> var: Ho, Ca
> param: r, o
>
> subject to answer_all {k in K}:
>    sum{(f,k) in R} (if (f,k) in O then 0 else  r[f,k]) = sum{(f,t) in L,
> (t,k) in O} o[t,k] * Ho[f,t,k];
>
> This works well, but when I change it to:
>
> subject to answer_all_requests {k in K}:
> sum{(f,k) in R} (if (f,k) in O or Ca[f,k] = 1 then 0 else r[f,k]) =
> sum{(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k];
>
> I get this errors:
> ###MINOS##
> MINOS 5.51: ignoring integrality of 6 variables
> MINOS 5.51: optimal solution found.
> 1 iterations, objective 12
> Nonlin evals: constrs = 3, Jac = 2.
>
> ##CPLEX###
> CPLEX 11.2.0: Constraint _scon[1] is not convex quadratic since it is
> an equality constraint.
>
> Thanks,
> eL Jey
>



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


[AMPL 2611] Re: Two vars in one constraint

by Thomas Granz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello Robert,

thank you, your answer helped me to understand.  But it is not
completely what I need. Because Ho is also dependent on Ca I would
like to write the constraint as follows:

    subject to answer_all_requests {k in K}:
       sum {(f,k) in R diff O} (1 - Ca[f,k]) * r[f,k] =
       sum {(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k] + sum{(f,t) in
L} Ca[t,k] * Ho[f,t,k];

But this is not linear as well. Is there a way to solve this with
CPLEX/MINOS ? Or is there a other solver which could help me? I have
the AMLP book and I am new to LP. Is there a good source to understand
nonlinear problems and how to make them linear?

Regards,
L J


On 24 Jun., 10:51, "Robert Fourer" <4...@...> wrote:

> MINOS does not recognize integer variables.  Also putting "Ca[f,k] = 1" in
> the "if" condition makes the constraint nonlinear, and CPLEX does not handle
> most linear constraints (the exception being certain convex quadratic ones
> mentioned in its error message).
>
> If Ca is a zero-one variable then you could try the following, though:
>
>    subject to answer_all_requests {k in K}:
>       sum {(f,k) in R diff O} (1 - Ca[f,k]) * r[f,k] =
>       sum {(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k];
>
> In general when modeling with integer variables and solving with CPLEX you
> need to use a trick of some kind to make your constraint linear in the
> variables.
>
> Bob Fourer
> 4...@...
>
> > -----Original Message-----
> > From: ampl@... [mailto:ampl@...]
> > On Behalf Of aL Jey [lukasban...@...]
> > Sent: Monday, June 22, 2009 9:20 AM
> > To: AMPL Modeling Language
> > Subject: [AMPL 2607] Two vars in one constraint
>
> > Hello everybody,
>
> > I tried to add a constraint into my model, but I get some errors from
> > cplex and  minos.
>
> > My first version of this constraint was:
>
> > sets: K, R, O, L
> > var: Ho, Ca
> > param: r, o
>
> > subject to answer_all {k in K}:
> >    sum{(f,k) in R} (if (f,k) in O then 0 else  r[f,k]) = sum{(f,t) in L,
> > (t,k) in O} o[t,k] * Ho[f,t,k];
>
> > This works well, but when I change it to:
>
> > subject to answer_all_requests {k in K}:
> >    sum{(f,k) in R} (if (f,k) in O or Ca[f,k] = 1 then 0 else r[f,k]) =
> > sum{(f,t) in L, (t,k) in O} o[t,k] * Ho[f,t,k];
>
> > I get this errors:
> > ###MINOS##
> > MINOS 5.51: ignoring integrality of 6 variables
> > MINOS 5.51: optimal solution found.
> > 1 iterations, objective 12
> > Nonlin evals: constrs = 3, Jac = 2.
>
> > ##CPLEX###
> > CPLEX 11.2.0: Constraint _scon[1] is not convex quadratic since it is
> > an equality constraint.
>
> > Thanks,
> > eL Jey
>
>

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