[AMPL 2536] Condicions in AMPL function

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

[AMPL 2536] Condicions in AMPL function

by plozmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Hi,
now I want to make this, using CPLEX

minimize totalcost:

 min(x,y)

How can I implement this statement? Can I with this solver?

Thanks to all,

--~--~---------~--~----~------------~-------~--~----~
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 2540] Re: Condicions in AMPL function

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I assume x and y are variables?  You'll need to introduce a binary
variable.

var z;  # objective value
var b binary;  # decides which of x and y is smaller
param M > 0;  # sufficiently large parameter that |x-y| < M for all
feasible x, y

minimize totalcost: z;
s.t. IfXSmaller: z >= x - M*b;
s.t. IfYSmaller: z >= y - M*(1-b);

On May 26, 5:12 am, plozmar <lozano_pal...@...> wrote:

> Hi,
> now I want to make this, using CPLEX
>
> minimize totalcost:
>
>  min(x,y)
>
> How can I implement this statement? Can I with this solver?
>
> Thanks to all,
--~--~---------~--~----~------------~-------~--~----~
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 2541] Re: Condicions in AMPL function

by plozmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks so much, but now I have problems with the parameter M because
it makes that the result optimization of the variables x and y
changes, I don´t know why. I take a big number (sufficiently large
that |x-y|) the values of x and y changes (and the program doesn´t
work ok) Why is it?

Thanks for all

On 26 mayo, 22:37, Paul <ru...@...> wrote:

> I assume x and y are variables?  You'll need to introduce a binary
> variable.
>
> var z;  # objective value
> var b binary;  # decides which of x and y is smaller
> param M > 0;  # sufficiently large parameter that |x-y| < M for all
> feasible x, y
>
> minimize totalcost: z;
> s.t. IfXSmaller: z >= x - M*b;
> s.t. IfYSmaller: z >= y - M*(1-b);
>
> On May 26, 5:12 am, plozmar <lozano_pal...@...> wrote:
>
>
>
> > Hi,
> > now I want to make this, using CPLEX
>
> > minimize totalcost:
>
> >  min(x,y)
>
> > How can I implement this statement? Can I with this solver?
>
> > Thanks to all,- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

--~--~---------~--~----~------------~-------~--~----~
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 2542] Re: Condicions in AMPL function

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The value of x and y changes from what?  Did you previously have a way
of solving the problem?

If you have a known optimal solution, check whether this approach
gives the same objective value but different x and y.  If the
objective value is the same, you have multiple optimal solutions.

Another possibility, if M is very large, is that rounding error may be
causing issues.  You generally want the smallest value of M for which
you can be confident that |x-y| < M.

On May 27, 6:53 am, plozmar <lozano_pal...@...> wrote:

> Thanks so much, but now I have problems with the parameter M because
> it makes that the result optimization of the variables x and y
> changes, I don´t know why. I take a big number (sufficiently large
> that |x-y|) the values of x and y changes (and the program doesn´t
> work ok) Why is it?
>
> Thanks for all
>
> On 26 mayo, 22:37, Paul <ru...@...> wrote:
>
> > I assume x and y are variables?  You'll need to introduce a binary
> > variable.
>
> > var z;  # objective value
> > var b binary;  # decides which of x and y is smaller
> > param M > 0;  # sufficiently large parameter that |x-y| < M for all
> > feasible x, y
>
> > minimize totalcost: z;
> > s.t. IfXSmaller: z >= x - M*b;
> > s.t. IfYSmaller: z >= y - M*(1-b);
>
> > On May 26, 5:12 am, plozmar <lozano_pal...@...> wrote:
>
> > > Hi,
> > > now I want to make this, using CPLEX
>
> > > minimize totalcost:
>
> > >  min(x,y)
>
> > > How can I implement this statement? Can I with this solver?
>
> > > Thanks to all,- Ocultar texto de la cita -
>
> > - Mostrar texto de la cita -
>
>
--~--~---------~--~----~------------~-------~--~----~
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 2626] Re: Condicions in AMPL function

by plozmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I´m in the same point that the last time I have writen here. I need to
obtain the minimum between two variables but with solution, the
variables X and Y, that they are before calcule in the program, change
the values and it doesn´t work... are there more methods of obtaining
a minimum in AMPL, using CPLEX?

Thanks

-------------
var z;  # objective value
var b binary;  # decides which of x and y is smaller
param M > 0;  # sufficiently large parameter that |x-y| < M for all
feasible x, y


minimize totalcost: z;
s.t. IfXSmaller: z >= x - M*b;
s.t. IfYSmaller: z >= y - M*(1-b);
--------------





On 27 mayo, 23:03, Paul <ru...@...> wrote:

> The value of x and y changes from what?  Did you previously have a way
> of solving the problem?
>
> If you have a known optimal solution, check whether this approach
> gives the same objective value but different x and y.  If the
> objective value is the same, you have multiple optimal solutions.
>
> Another possibility, if M is very large, is that rounding error may be
> causing issues.  You generally want the smallest value of M for which
> you can be confident that |x-y| < M.
>
> On May 27, 6:53 am,plozmar<lozano_pal...@...> wrote:
>
>
>
> > Thanks so much, but now I have problems with the parameter M because
> > it makes that the result optimization of the variables x and y
> > changes, I don´t know why. I take a big number (sufficiently large
> > that |x-y|) the values of x and y changes (and the program doesn´t
> > work ok) Why is it?
>
> > Thanks for all
>
> > On 26 mayo, 22:37, Paul <ru...@...> wrote:
>
> > > I assume x and y are variables?  You'll need to introduce a binary
> > > variable.
>
> > > var z;  # objective value
> > > var b binary;  # decides which of x and y is smaller
> > > param M > 0;  # sufficiently large parameter that |x-y| < M for all
> > > feasible x, y
>
> > > minimize totalcost: z;
> > > s.t. IfXSmaller: z >= x - M*b;
> > > s.t. IfYSmaller: z >= y - M*(1-b);
>
> > > On May 26, 5:12 am,plozmar<lozano_pal...@...> wrote:
>
> > > > Hi,
> > > > now I want to make this, using CPLEX
>
> > > > minimize totalcost:
>
> > > >  min(x,y)
>
> > > > How can I implement this statement? Can I with this solver?
>
> > > > Thanks to all,- Ocultar texto de la cita -
>
> > > - Mostrar texto de la cita -- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---