[AMPL 15123] Medeling non linear problem

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

[AMPL 15123] Medeling non linear problem

Cristian Vera
Hi.
I am new in AMPL and I am not good for English, excuse me.
I am trying to model a inventory problem with fullbackorders in AMPL using MINOS solver, with an objective function that is minimize global cost.
The is that:
#Modelo de Tarea 2 de Inventarios
set I;

param w{I}>=0;
param Cp{I}>=0;
param Ca{I}>=0;
param Ch{I}>=0;
param Cb{I}>=0;
param alfa{I}>=0;
param beta{I}>=0;
param p{I}>=0;
param D{I}>=0;
param d{I}>=0;
param S{I}>=0;
param a{I}>=0;
param b{I}>=0;
param L{I}>=0;

#Variables decision
var Q{I}>=0;
var X{I};
var J{I};
var K{I};
var M{I};
var t0{I}>=0;
var t1{I}>=0;
var t2{I}>=0;
var t3{I}>=0;
var t4{I}>=0;
var T{I}>=0;

#Funcion objetivo
minimize objetivo: sum {i in I} (Cp[i]*Q[i]+D[i]*S[i]/Q[i]+J[i]*Ch[i]+K[i]*Ca[i]+Cb[i]*M[i]);

#Restricciones
subject to R1: J{I}=((w{I}*t0/2+w{I}*t1+w{I}*t2+w{I}*t3)/T);
subject to R2: K{I}=(((Q{I}-w{I})*t1/2+(Q{I}-w{I})*t2/2)/T);
subject to R3: M{I}=((X{I}*t4/2)/T);
subject to R4: t0= ((w{I}/(p{I}-alfa{I}-d{I}));
subject to R5: t1= ((Q{I}-w{I})/(p{I}-beta{I}-d{I}));
subject to R6: t2= ((Q{I}-w{I})/(d{I}+beta{I}));
subject to R7: t3=(w{I}/(d{I}+alfa{I}));
subject to R8: t4=(X{I}/(d{I}+alfa{I}));
subject to R9: T=t0+t1+t2+t3+t4;

In the mark line with yellow, AMPL found a error of sintaxis that the message is Offset 563.

Can you help me please, I will be so grateful with your help.
Thanks and best regards

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15128] Medeling non linear problem

Robert Fourer-2
You need to follow the AMPL syntax in writing the constraints.  For example,

   subject to R1 {i in I}: J[i]=((w[i]*t0/2+w[i]*t1+w[i]*t2+w[i]*t3)/T);

Also for this to be correct you should define "var T >= 0;" rather than var T{I} >= 0;", and similarly for t0, t1, t2, and t3.

Bob Fourer
[hidden email]

=======

From: [hidden email] [mailto:[hidden email]] On Behalf Of Cristian Vera
Sent: Wednesday, November 15, 2017 3:42 PM
To: AMPL Modeling Language
Subject: [AMPL 15123] Medeling non linear problem

I am new in AMPL and I am not good for English, excuse me.
I am trying to model a inventory problem with fullbackorders in AMPL using MINOS solver, with an objective function that is minimize global cost.
The is that:

#Modelo de Tarea 2 de Inventarios
set I;

param w{I}>=0;
param Cp{I}>=0;
param Ca{I}>=0;
param Ch{I}>=0;
param Cb{I}>=0;
param alfa{I}>=0;
param beta{I}>=0;
param p{I}>=0;
param D{I}>=0;
param d{I}>=0;
param S{I}>=0;
param a{I}>=0;
param b{I}>=0;
param L{I}>=0;

#Variables decision
var Q{I}>=0;
var X{I};
var J{I};
var K{I};
var M{I};
var t0{I}>=0;
var t1{I}>=0;
var t2{I}>=0;
var t3{I}>=0;
var t4{I}>=0;
var T{I}>=0;

#Funcion objetivo
minimize objetivo: sum {i in I} (Cp[i]*Q[i]+D[i]*S[i]/Q[i]+J[i]*Ch[i]+K[i]*Ca[i]+Cb[i]*M[i]);

#Restricciones
subject to R1: J{I}=((w{I}*t0/2+w{I}*t1+w{I}*t2+w{I}*t3)/T);
subject to R2: K{I}=(((Q{I}-w{I})*t1/2+(Q{I}-w{I})*t2/2)/T);
subject to R3: M{I}=((X{I}*t4/2)/T);
subject to R4: t0= ((w{I}/(p{I}-alfa{I}-d{I}));
subject to R5: t1= ((Q{I}-w{I})/(p{I}-beta{I}-d{I}));
subject to R6: t2= ((Q{I}-w{I})/(d{I}+beta{I}));
subject to R7: t3=(w{I}/(d{I}+alfa{I}));
subject to R8: t4=(X{I}/(d{I}+alfa{I}));
subject to R9: T=t0+t1+t2+t3+t4;

In the mark line with yellow, AMPL found a error of sintaxis that the message is Offset 563.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 15132] Medeling non linear problem

Cristian Vera
Thanks you for the answer, help me a lot for the result of this problem.
Another question, if you can help me again, How I can get the shadow price with a function? or only I can obtain this shadow price manually, changing the constraint that I need?

Thanks for your help, Bob Fourer.


El jueves, 16 de noviembre de 2017, 17:00:33 (UTC-3), Robert Fourer escribió:
You need to follow the AMPL syntax in writing the constraints.  For example,

   subject to R1 {i in I}: J[i]=((w[i]*t0/2+w[i]*t1+w[i]*t2+w[i]*t3)/T);

Also for this to be correct you should define "var T >= 0;" rather than var T{I} >= 0;", and similarly for t0, t1, t2, and t3.

Bob Fourer
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LypwmjhgBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...

=======

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LypwmjhgBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LypwmjhgBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...] On Behalf Of Cristian Vera
Sent: Wednesday, November 15, 2017 3:42 PM
To: AMPL Modeling Language
Subject: [AMPL 15123] Medeling non linear problem

I am new in AMPL and I am not good for English, excuse me.
I am trying to model a inventory problem with fullbackorders in AMPL using MINOS solver, with an objective function that is minimize global cost.
The is that:

#Modelo de Tarea 2 de Inventarios
set I;

param w{I}>=0;
param Cp{I}>=0;
param Ca{I}>=0;
param Ch{I}>=0;
param Cb{I}>=0;
param alfa{I}>=0;
param beta{I}>=0;
param p{I}>=0;
param D{I}>=0;
param d{I}>=0;
param S{I}>=0;
param a{I}>=0;
param b{I}>=0;
param L{I}>=0;

#Variables decision
var Q{I}>=0;
var X{I};
var J{I};
var K{I};
var M{I};
var t0{I}>=0;
var t1{I}>=0;
var t2{I}>=0;
var t3{I}>=0;
var t4{I}>=0;
var T{I}>=0;

#Funcion objetivo
minimize objetivo: sum {i in I} (Cp[i]*Q[i]+D[i]*S[i]/Q[i]+J[i]*Ch[i]+K[i]*Ca[i]+Cb[i]*M[i]);

#Restricciones
subject to R1: J{I}=((w{I}*t0/2+w{I}*t1+w{I}*t2+w{I}*t3)/T);
subject to R2: K{I}=(((Q{I}-w{I})*t1/2+(Q{I}-w{I})*t2/2)/T);
subject to R3: M{I}=((X{I}*t4/2)/T);
subject to R4: t0= ((w{I}/(p{I}-alfa{I}-d{I}));
subject to R5: t1= ((Q{I}-w{I})/(p{I}-beta{I}-d{I}));
subject to R6: t2= ((Q{I}-w{I})/(d{I}+beta{I}));
subject to R7: t3=(w{I}/(d{I}+alfa{I}));
subject to R8: t4=(X{I}/(d{I}+alfa{I}));
subject to R9: T=t0+t1+t2+t3+t4;

In the mark line with yellow, AMPL found a error of sintaxis that the message is Offset 563.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15144] Medeling non linear problem

Robert Fourer-2
Use the suffix .dual to get shadow prices returned by MINOS.  For example, "display R1.dual;" will give you the shadow prices for the R1 constraints.

Bob Fourer
[hidden email]

=======

From: [hidden email] [mailto:[hidden email]] On Behalf Of Cristian Vera
Sent: Thursday, November 16, 2017 5:12 PM
To: AMPL Modeling Language
Subject: Re: [AMPL 15132] Medeling non linear problem

Another question, if you can help me again, How I can get the shadow price with a function? or only I can obtain this shadow price manually, changing the constraint that I need?


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 15156] Medeling non linear problem

Cristian Vera
Thank for everything, your answer result to useful in the problem.
Best regards.

El viernes, 17 de noviembre de 2017, 16:48:16 (UTC-3), Robert Fourer escribió:
Use the suffix .dual to get shadow prices returned by MINOS.  For example, "display R1.dual;" will give you the shadow prices for the R1 constraints.

Bob Fourer
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZfhIjyGuBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...

=======

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZfhIjyGuBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZfhIjyGuBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...] On Behalf Of Cristian Vera
Sent: Thursday, November 16, 2017 5:12 PM
To: AMPL Modeling Language
Subject: Re: [AMPL 15132] Medeling non linear problem

Another question, if you can help me again, How I can get the shadow price with a function? or only I can obtain this shadow price manually, changing the constraint that I need?


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15161] Medeling non linear problem

Cristian Vera
In reply to this post by Robert Fourer-2
Excuse me, I can make another question? If i need to change the solver for a Global Optimization and I don't have the LGO Solver, Exist another solver that I can use like substitute?
Thank you so much for help me.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15176] Medeling non linear problem

Robert Fourer-2
Two global solvers that are often used with AMPL are Couenne, which you can download free from http://ampl.com/products/solvers/open-source/, and BARON, which is described at http://ampl.com/products/solvers/solvers-we-sell/baron/.

Bob Fourer
[hidden email]


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Cristian Vera
Sent: Sunday, November 19, 2017 6:53 PM
To: AMPL Modeling Language
Subject: RE: [AMPL 15161] Medeling non linear problem

If i need to change the solver for a Global Optimization and I don't have the LGO Solver, Exist another solver that I can use like substitute?


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 15189] Medeling non linear problem

Cristian Vera
Thank you so much.
If I change the demand to stochastic in the form of a normal distribution with known average and standard deviation , Exist a command that give me random values of demand? and finally, include them in the model with a command for but How I use the command for if I need 1000 different results to the model and show them?
I hope that the question be understood, I was difficult to me write them.
Thank you for your help, for you I learn so much to use this program.

El lunes, 20 de noviembre de 2017, 20:46:27 (UTC-3), Robert Fourer escribió:
Two global solvers that are often used with AMPL are Couenne, which you can download free from <a href="http://ampl.com/products/solvers/open-source/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fampl.com%2Fproducts%2Fsolvers%2Fopen-source%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFATkAot7soWARCdqmpEZgFsu-piw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fampl.com%2Fproducts%2Fsolvers%2Fopen-source%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFATkAot7soWARCdqmpEZgFsu-piw&#39;;return true;">http://ampl.com/products/solvers/open-source/, and BARON, which is described at <a href="http://ampl.com/products/solvers/solvers-we-sell/baron/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fampl.com%2Fproducts%2Fsolvers%2Fsolvers-we-sell%2Fbaron%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRTt13AlE2uPtX8maUliMocoOzqA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fampl.com%2Fproducts%2Fsolvers%2Fsolvers-we-sell%2Fbaron%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRTt13AlE2uPtX8maUliMocoOzqA&#39;;return true;">http://ampl.com/products/solvers/solvers-we-sell/baron/.

Bob Fourer
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="V8bkjt6mCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...


-----Original Message-----
From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="V8bkjt6mCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="V8bkjt6mCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...] On Behalf Of Cristian Vera
Sent: Sunday, November 19, 2017 6:53 PM
To: AMPL Modeling Language
Subject: RE: [AMPL 15161] Medeling non linear problem

If i need to change the solver for a Global Optimization and I don't have the LGO Solver, Exist another solver that I can use like substitute?


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15200] Medeling non linear problem

Robert Fourer-2
There is an AMPL function Normal(mean,stdev) that returns a random value chosen from a normal distribution with the given mean and standard deviation; you can substitute any valid AMPL expression for "mean" and for "stdev".  Thus, as a simple example, if you define

   param demand {t in 1..T} = Normal(10,1);

then the value of each param demand[t] will be a different random sample from a normal distribution with mean 10 and standard deviation 1.  Furthermore the command

   reset data demand;

will reset the demand[t] values to new random samples; you can use this command inside a for loop to solve with many different random choices.

Bob Fourer
[hidden email]

=======

From: [hidden email] [mailto:[hidden email]] On Behalf Of Cristian Vera
Sent: Tuesday, November 21, 2017 7:42 PM
To: AMPL Modeling Language
Subject: Re: [AMPL 15189] Medeling non linear problem

If I change the demand to stochastic in the form of a normal distribution with known average and standard deviation , Exist a command that give me random values of demand? and finally, include them in the model with a command for but How I use the command for if I need 1000 different results to the model and show them?
I hope that the question be understood, I was difficult to me write them.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 15278] Medeling non linear problem

Cristian Vera
Hi Bob.
You help me so much for this problem, and I hope that you can help me with another problem please, if you can?
I have a linear problem of production of five products with different amount of raw material that are three, in the other side I have two warehouse, the first is mine and the other I lease this with a different cost in the time. All of this in 26 weeks and I search the minimum cost feasible.

I model this problem in the attach files, because is so large to put them here. But I have an error in the formula of the product, specifically in the constraint two that give me an error that they can't compute receta[4,1] (formula of the 4 product with the 1 raw material) and I don't understand why is wrong in this model, because if I  separate this constraint and I don't occupy this constraint (R2, var V and the firs componente of the objective) all runs good (but is so delay).

Thank you so much, I so grateful with us.

El jueves, 23 de noviembre de 2017, 16:00:03 (UTC-3), Robert Fourer escribió:
There is an AMPL function Normal(mean,stdev) that returns a random value chosen from a normal distribution with the given mean and standard deviation; you can substitute any valid AMPL expression for "mean" and for "stdev".  Thus, as a simple example, if you define

   param demand {t in 1..T} = Normal(10,1);

then the value of each param demand[t] will be a different random sample from a normal distribution with mean 10 and standard deviation 1.  Furthermore the command

   reset data demand;

will reset the demand[t] values to new random samples; you can use this command inside a for loop to solve with many different random choices.

Bob Fourer
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="egAG1Y4mAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...

=======

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="egAG1Y4mAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="egAG1Y4mAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...] On Behalf Of Cristian Vera
Sent: Tuesday, November 21, 2017 7:42 PM
To: AMPL Modeling Language
Subject: Re: [AMPL 15189] Medeling non linear problem

If I change the demand to stochastic in the form of a normal distribution with known average and standard deviation , Exist a command that give me random values of demand? and finally, include them in the model with a command for but How I use the command for if I need 1000 different results to the model and show them?
I hope that the question be understood, I was difficult to me write them.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Datos.dat (3K) Download Attachment
modelo.mod (2K) Download Attachment
run.run (157 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 15285] Medeling non linear problem

Robert Fourer-2
You defined "param receta{J,I};" so in your sum over "{i in I, j in J}" you need to write receta[j,i].

Bob Fourer
[hidden email]

=======

From: [hidden email] [mailto:[hidden email]] On Behalf Of Cristian Vera
Sent: Sunday, December 3, 2017 12:08 AM
To: AMPL Modeling Language
Subject: Re: [AMPL 15278] Medeling non linear problem

I have a linear problem of production of five products with different amount of raw material that are three, in the other side I have two warehouse, the first is mine and the other I lease this with a different cost in the time. All of this in 26 weeks and I search the minimum cost feasible.

I model this problem in the attach files, because is so large to put them here. But I have an error in the formula of the product, specifically in the constraint two that give me an error that they can't compute receta[4,1] (formula of the 4 product with the 1 raw material) and I don't understand why is wrong in this model, because if I  separate this constraint and I don't occupy this constraint (R2, var V and the firs componente of the objective) all runs good (but is so delay).


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.