Variables Problem

Problems with modeling
Post Reply
milvetti
User
User
Posts: 1
Joined: 4 years ago

Variables Problem

Post by milvetti »

Hi everyone i am learning gams for a while so i don't have knowledge enough.
I have gotten error that division by zero for all equations without "amac". How can i fix it?
Have a nice day. If i have created this topic in wrong category i am sorry

Code: Select all

set
i seasons /1,2,3,4,5,6/
j types /1,2,3,4/;

table d(i,j) info
         1       2       3       4
1        990     105     45      475
2        1310    140     63      653
3        1628    210     96      799
4        1553    153     74      758
5        1336    120     65      656
6        1057    111     50      512

variables
g(i) alinacak garson sayisi
t(i) alinacak temizlikci sayisi
m(i) alinacak meydanci sayisi
b(i) alinacak bagaj tasiyici sayisi
v(i) alinacak vale sayisi
z minimum calisan;

positive variables
g(i)
t(i)
m(i)
b(i)
v(i);

free variables
z;
equations

amac
k1 , k2 , k3 , k4 , k5 , k6 , k7 , k8 , k9, k10 , k11 , k12 , k13 , k14 , k15 , k16 , k17 , k18 , k19 , k20 , k21 , k22 , k23 , k24 , k25 , k26 , k27 , k28 , k29 , k30 ;

k1.. d('1','4') / g('1') =L= 5 ;
k2.. d('2','4') / ( g('2') + g('1') ) =L= 5 ;
k3.. d('3','4') / ( g('3') + g('2') ) =L= 5 ;
k4.. d('4','4') / ( g('4') + g('3') ) =L= 5 ;
k5.. d('5','4') / ( g('5') + g('4') ) =L= 5 ;
k6.. d('6','4') / ( g('6') + g('5') ) =L= 5 ;

k7.. d('1','4') / t('1') =L= 5 ;
k8.. d('2','4') / ( t('2') + t('1') ) =L= 14 ;
k9.. d('3','4') / ( t('3') + t('2') ) =L= 14 ;
k10.. d('4','4') / ( t('4') + t('3') ) =L= 14 ;
k11.. d('5','4') / ( t('5') + t('4') ) =L= 14 ;
k12.. d('6','4') / ( t('6') + t('5') ) =L= 14 ;

k13.. d('1','1') / m('1') =L= 7 ;
k14.. d('2','1') / ( m('2') + m('1') ) =L= 7 ;
k15.. d('3','1') / ( m('3') + m('2') ) =L= 7 ;
k16.. d('4','1') / ( m('4') + m('3') ) =L= 7 ;
k17.. d('5','1') / ( m('5') + m('4') ) =L= 7 ;
k18.. d('6','1') / ( m('6') + m('5') ) =L= 7 ;

k19.. d('1','2') / b('1') =L= 18 ;
k20.. d('2','2') / ( b('2') + b('1') ) =L= 18 ;
k21.. d('3','2') / ( b('3') + b('2') ) =L= 18 ;
k22.. d('4','2') / ( b('4') + b('3') ) =L= 18 ;
k23.. d('5','2') / ( b('5') + b('4') ) =L= 18 ;
k24.. d('6','2') / ( b('6') + b('5') ) =L= 18 ;

k25.. d('1','3') / v('1') =L= 20 ;
k26.. d('2','3') / ( v('2') + v('1') ) =L= 20 ;
k27.. d('3','3') / ( v('3') + v('2') ) =L= 20 ;
k28.. d('4','3') / ( v('4') + v('3') ) =L= 20 ;
k29.. d('5','3') / ( v('5') + v('4') ) =L= 20 ;
k30.. d('6','3') / ( v('6') + v('5') ) =L= 20 ;


amac.. z =E= g('1')*3300+t('1')*2950+m('1')*3000+b('1')*2750+v('1')*3150+(g('2')+g('3')+g('4')+g('5')+g('6'))*3750+(t('2')+t('3')+t('4')+t('5')+t('6'))*3220+(b('2')+b('3')+b('4')+b('5')+b('6'))*3100+(m('2')+m('3')+m('4')+m('5')+m('6'))*3450+(v('2')+v('3')+v('4')+v('5')+v('6'))*3500;

Model Untitled_3 /
k1 , k2 , k3 , k4 , k5 , k6 , k7 , k8 , k9, k10 , k11 , k12 , k13 , k14 , k15 , k16 , k17 , k18 , k19 , k20 , k21 , k22 , k23 , k24 , k25 , k26 , k27 , k28 , k29 , k30 ,
amac / ;



Solve Untitled_3 using nlp minimizing z ;

User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Variables Problem

Post by Renger »

Hi
Welcome to the forum! This is one of the most asked questions. Just search for "division by zero" in this forum and you will find the answer.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: Variables Problem

Post by bussieck »

In your particular case the answer seems even simpler: Just just multiply by the divisor, e.g. k2.. d('2','4') =L= 5 * ( g('2') + g('1') ); and end up with an LP rather than an non-convex NLP?

-Michael
anil
User
User
Posts: 3
Joined: 3 years ago

Re: Variables Problem

Post by anil »

Hi;

I need Gams coding of the problem according to the model. Can you help?
English Exam.JPG
project_math_model.pdf
(202.71 KiB) Downloaded 231 times
Post Reply