Unexpected Error: x**y, x<0

Dear Friends,

I have a GAMS code, in which I have a constraint ( something like x>0) and x**y in the model. I do not know why GAMS does not satisfy the constraint and shows error.

The real code is

SCALARS r1 the manufacturer capacity utilization /0.9/
q deteriorating rate which is a fraction of the on-hand inventory /0.1/
Ip manufacturer opportunity cost per dollar per unit time /0.06/
M the manufacturer trade credit period offered by the supplier / 0.0821917808219178/
N the customer trade credit period offered by the manufacturer / 0.0410958904109589/
k constant in the manufacturer demand function representing his market scale /5000000/
e price elasticity of manufacturer demand rate which is alpha in the thesis /1.5/ ;

VARIABLES
z5 total net profit ;
POSITIVE VARIABLES
T1 production time with backorder at manufacturer’s side
T2 production time when positive stock builds up and the stock depletes due to the demand and deterioration at manufacturers side
v the unit price charged by the manufacturer to the customers ;
T1.lo = 0.01 ;
T2.lo = 0.01 ;
v.lo = 1 ;
T1.up = 2 ;
T2.up = 2 ;

Equations
Profit define objective function
Constraint1 condition1 for NP5
Constraint2 condition2 for NP5 ;

Profit … z5 =e= ((T1+T2+((1/q)(log((1-(1/r1))exp(-qT2)+(1/r1))))+N-M)**2) ;
Constraint1 … M =g= T1+T2+(1/q)
(log((1-(1/r1))exp(-qT2)+(1/r1))) ;
Constraint2 … M =l= T1+T2+(1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1)))+N ;

MODEL NetProfit /ALL/ ;
SOLVE NetProfit USING NLP MINIMIZING z5 ;
option decimals=8 ;
Display z5.l;
Display T1.l, T2.l, v.l;

However, when I change the lower bound of T2 from 0.01 to 0.03, it would be considered as the optimal value for T2 and does not give error anymore. But, it is not logical! And when I use multiplication instead of power, it finds zero as the answer while the lower bounds are greater.

I would highly appreciate it if you can help me solve this problem.

Best regards.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Zohreh

The starting value of the expression to be raised to the power of 2 in the profit is a negative number.

If you write this as power(expression, 2) this will work fine.

Cheers

Renger


\


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Zohreh
Sent: Freitag, 31. Januar 2014 06:27
To: gamsworld@googlegroups.com
Subject: Unexpected Error: xy, x0) and xy in the model. I do not know why GAMS does not satisfy the constraint and shows error.



The real code is



SCALARS r1 the manufacturer capacity utilization /0.9/

q deteriorating rate which is a fraction of the on-hand inventory /0.1/

Ip manufacturer opportunity cost per dollar per unit time /0.06/

M the manufacturer trade credit period offered by the supplier / 0.0821917808219178/

N the customer trade credit period offered by the manufacturer / 0.0410958904109589/

k constant in the manufacturer demand function representing his market scale /5000000/

e price elasticity of manufacturer demand rate which is alpha in the thesis /1.5/ ;



VARIABLES

z5 total net profit ;

POSITIVE VARIABLES

T1 production time with backorder at manufacturer’s side

T2 production time when positive stock builds up and the stock depletes due to the demand and deterioration at manufacturers side

v the unit price charged by the manufacturer to the customers ;

T1.lo = 0.01 ;

T2.lo = 0.01 ;

v.lo = 1 ;

T1.up = 2 ;

T2.up = 2 ;



Equations

Profit define objective function

Constraint1 condition1 for NP5

Constraint2 condition2 for NP5 ;



Profit … z5 =e= ((T1+T2+((1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1))))+N-M)**2) ;

Constraint1 … M =g= T1+T2+(1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1))) ;

Constraint2 … M =l= T1+T2+(1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1)))+N ;



MODEL NetProfit /ALL/ ;

SOLVE NetProfit USING NLP MINIMIZING z5 ;

option decimals=8 ;

Display z5.l;

Display T1.l, T2.l, v.l;



However, when I change the lower bound of T2 from 0.01 to 0.03, it would be considered as the optimal value for T2 and does not give error anymore. But, it is not logical! And when I use multiplication instead of power, it finds zero as the answer while the lower bounds are greater.



I would highly appreciate it if you can help me solve this problem.



Best regards.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Dear Renger,

Thanks a lot for your response.

I do not get it what you mean by writing it as power(expression, 2). I would highly appreciate it if you explain more.

Best regards.



On Friday, January 31, 2014 1:26:40 PM UTC+8, Zohreh wrote:

Dear Friends,

I have a GAMS code, in which I have a constraint ( something like x>0) and x**y in the model. I do not know why GAMS does not satisfy the constraint and shows error.

The real code is

SCALARS r1 the manufacturer capacity utilization /0.9/
q deteriorating rate which is a fraction of the on-hand inventory /0.1/
Ip manufacturer opportunity cost per dollar per unit time /0.06/
M the manufacturer trade credit period offered by the supplier / 0.0821917808219178/
N the customer trade credit period offered by the manufacturer / 0.0410958904109589/
k constant in the manufacturer demand function representing his market scale /5000000/
e price elasticity of manufacturer demand rate which is alpha in the thesis /1.5/ ;

VARIABLES
z5 total net profit ;
POSITIVE VARIABLES
T1 production time with backorder at manufacturer’s side
T2 production time when positive stock builds up and the stock depletes due to the demand and deterioration at manufacturers side
v the unit price charged by the manufacturer to the customers ;
T1.lo = 0.01 ;
T2.lo = 0.01 ;
v.lo = 1 ;
T1.up = 2 ;
T2.up = 2 ;

Equations
Profit define objective function
Constraint1 condition1 for NP5
Constraint2 condition2 for NP5 ;

Profit … z5 =e= ((T1+T2+((1/q)(log((1-(1/r1))exp(-qT2)+(1/r1))))+N-M)**2) ;
Constraint1 … M =g= T1+T2+(1/q)
(log((1-(1/r1))exp(-qT2)+(1/r1))) ;
Constraint2 … M =l= T1+T2+(1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1)))+N ;

MODEL NetProfit /ALL/ ;
SOLVE NetProfit USING NLP MINIMIZING z5 ;
option decimals=8 ;
Display z5.l;
Display T1.l, T2.l, v.l;

However, when I change the lower bound of T2 from 0.01 to 0.03, it would be considered as the optimal value for T2 and does not give error anymore. But, it is not logical! And when I use multiplication instead of power, it finds zero as the answer while the lower bounds are greater.

I would highly appreciate it if you can help me solve this problem.

Best regards.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Hi
You can write the square of something either as

  • x*x
  • x**2
  • power(x,2)
    In your equation you take the square of an expression (including r, n, m etc.)
    You only have to use the power function instead of **.
    Cheers
    Renger

Sent from my iPhone

Am 31.01.2014 um 15:49 schrieb “Zohreh” :

Dear Renger,

Thanks a lot for your response.

I do not get it what you mean by writing it as power(expression, 2). I would highly appreciate it if you explain more.

Best regards.

On Friday, January 31, 2014 1:26:40 PM UTC+8, Zohreh wrote:

Dear Friends,

I have a GAMS code, in which I have a constraint ( something like x>0) and x**y in the model. I do not know why GAMS does not satisfy the constraint and shows error.

The real code is

SCALARS  r1  the manufacturer capacity utilization  /0.9/
          q  deteriorating rate which is a fraction of the on-hand inventory  /0.1/
         Ip  manufacturer opportunity cost per dollar per unit time  /0.06/
          M  the manufacturer trade credit period offered by the supplier  / 0.0821917808219178/
          N  the customer trade credit period offered by the manufacturer  / 0.0410958904109589/
          k  constant in the manufacturer demand function representing his market scale  /5000000/
          e  price elasticity of manufacturer demand rate which is alpha in the thesis /1.5/ ;

  VARIABLES
       z5       total net profit ;
  POSITIVE VARIABLES
       T1  production time with backorder at manufacturer's side
       T2  production time when positive stock builds up and the stock depletes due to the demand and deterioration at manufacturers side
       v  the unit price charged by the manufacturer to the customers  ;
       T1.lo = 0.01  ;
       T2.lo = 0.01 ;
       v.lo = 1  ;
       T1.up = 2  ;
       T2.up = 2  ;

    Equations
       Profit               define objective function
       Constraint1          condition1 for NP5
       Constraint2          condition2 for NP5 ;

  Profit  ..                z5  =e=  ((T1+T2+((1/q)*(log((1-(1/r1))*exp(-q*T2)+(1/r1))))+N-M)**2)  ;
  Constraint1  ..           M  =g=  T1+T2+(1/q)*(log((1-(1/r1))*exp(-q*T2)+(1/r1)))  ;
  Constraint2  ..           M  =l=  T1+T2+(1/q)*(log((1-(1/r1))*exp(-q*T2)+(1/r1)))+N  ;

  MODEL NetProfit /ALL/ ;
  SOLVE NetProfit USING NLP MINIMIZING z5 ;
  option decimals=8 ;
  Display z5.l;
  Display T1.l, T2.l, v.l;

However, when I change the lower bound of T2 from 0.01 to 0.03, it would be considered as the optimal value for T2 and does not give error anymore. But, it is not logical! And when I use multiplication instead of power, it finds zero as the answer while the lower bounds are greater.

I would highly appreciate it if you can help me solve this problem.

Best regards.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Dear Renger,

Thank you very much for your help and prompt response.

Best regards.


On Friday, January 31, 2014 1:26:40 PM UTC+8, Zohreh wrote:

Dear Friends,

I have a GAMS code, in which I have a constraint ( something like x>0) and x**y in the model. I do not know why GAMS does not satisfy the constraint and shows error.

The real code is

SCALARS r1 the manufacturer capacity utilization /0.9/
q deteriorating rate which is a fraction of the on-hand inventory /0.1/
Ip manufacturer opportunity cost per dollar per unit time /0.06/
M the manufacturer trade credit period offered by the supplier / 0.0821917808219178/
N the customer trade credit period offered by the manufacturer / 0.0410958904109589/
k constant in the manufacturer demand function representing his market scale /5000000/
e price elasticity of manufacturer demand rate which is alpha in the thesis /1.5/ ;

VARIABLES
z5 total net profit ;
POSITIVE VARIABLES
T1 production time with backorder at manufacturer’s side
T2 production time when positive stock builds up and the stock depletes due to the demand and deterioration at manufacturers side
v the unit price charged by the manufacturer to the customers ;
T1.lo = 0.01 ;
T2.lo = 0.01 ;
v.lo = 1 ;
T1.up = 2 ;
T2.up = 2 ;

Equations
Profit define objective function
Constraint1 condition1 for NP5
Constraint2 condition2 for NP5 ;

Profit … z5 =e= ((T1+T2+((1/q)(log((1-(1/r1))exp(-qT2)+(1/r1))))+N-M)**2) ;
Constraint1 … M =g= T1+T2+(1/q)
(log((1-(1/r1))exp(-qT2)+(1/r1))) ;
Constraint2 … M =l= T1+T2+(1/q)*(log((1-(1/r1))exp(-qT2)+(1/r1)))+N ;

MODEL NetProfit /ALL/ ;
SOLVE NetProfit USING NLP MINIMIZING z5 ;
option decimals=8 ;
Display z5.l;
Display T1.l, T2.l, v.l;

However, when I change the lower bound of T2 from 0.01 to 0.03, it would be considered as the optimal value for T2 and does not give error anymore. But, it is not logical! And when I use multiplication instead of power, it finds zero as the answer while the lower bounds are greater.

I would highly appreciate it if you can help me solve this problem.

Best regards.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.