Divided by 0

It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i

\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi Daniel



If you don’t give starting values for your variables, GAMS will use 0, causing this error. You could either write for every variable a non-zero starting value or put a very small lower bound on this variable, e.g.

Por.l(e) =1;

Or

Por.lo(e) = 0.00001;



Cheers

Renger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch







Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von edemerz@gmail.com
Gesendet: Dienstag, 5. Februar 2013 01:31
An: gamsworld@googlegroups.com
Betreff: Divided by 0



It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i


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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi
1- add the term
por.lo(e)=1e-5;
2- delete the term $ (por(e) gt 0) from “Empresas”


On Tue, Feb 5, 2013 at 4:00 AM, wrote:

It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i

\

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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi
1- add the term
por.lo(e)=1e-5;
after variable declaration
2- delete the term $ (por(e) gt 0) from “Empresas”


On Tue, Feb 5, 2013 at 11:03 AM, A.R. Bahari wrote:

Hi
1- add the term
por.lo(e)=1e-5;
2- delete the term $ (por(e) gt 0) from “Empresas”

On Tue, Feb 5, 2013 at 4:00 AM, wrote:

It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


\

Thank you very much, it worked perfectly

On Monday, February 4, 2013 7:30:33 PM UTC-5, ede...@gmail.com wrote:

It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i

\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

hi Daniel,

I have same problem,please tell me how does the Renger guide( Por.l(e) =1;) means where Wrote the Por.l(e) =1; in your program?

Thanks
MEHRDAD


On Tue, Feb 5, 2013 at 6:39 PM, wrote:

Thank you very much, it worked perfectly


On Monday, February 4, 2013 7:30:33 PM UTC-5, ede...@gmail.com wrote:

It has been a long while since I have used GAMS, but today I started to use it again and have been having a problem.
When I run my program I get a divided by 0 error, I think that it is my por(e) variable. Is it possible to either make this variable strictly greater than 0 or better yet, in case that it is 0 to not include it in the sum?

Thanks,

Daniel

Sets
e Tipos de empresas /g, m, p/ ;

Parameters
Em(e) Empleados por tipo de empresa
/ g 15
m 5
p 1 /
V(e) # de visitas por tipo de empresa
/g 4
m 3
p 2/
Con(e) Efectividad en la consecución de empresas
/g 0.25
m 0.5
p 0.75/ ;
Scalar T Tiempo empleado en la consecucíon de empresas
/64/ ;
Variables
x(e) numero de empresas a conseguir
por(e) porcentaje de tiempo utilizado en la consecución de empresas
i ingresos;

positive variable x(e)
Positive variable por(e) ;

Equations
ingresos funcion objetivo
empresas funcion de consecucion de empresas
porcentual limite del tiempo;

ingresos… i =e= sum(e, Em(e)*x(e));
porcentual… sum(e, por(e)) =e= 1;
empresas… sum(e$ (por(e) gt 0) ,(x(e)*V(e)*Con(e))/(por(e))) =l= T;

Model ensayo /all/;

Solve ensayo using nlp maximizing i

\

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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\