to write objective function

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

to write objective function

Post by Archiver »


Hi,

my objective function as is follow;


ΣΣ𝐗𝐃𝐢,𝐤 + 𝐗𝐍𝐢,𝐤 + 𝐗𝐑𝐢,𝐤 for all i and k value

and my gams code as is follow;

Amac.. sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k) =e=z;

but this syntax has error. what is true sytax for this objective function?

sincerely..

--
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: to write objective function

Post by Archiver »


Hi Frank,

thank you for your answer.
i think i didn't understood very well.
after your suggestion my model is as follow;

Amac.. (sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k)) =e=z;

but still i have an error.



1 Mart 2016 Salı 16:36:18 UTC+2 tarihinde Frank Ward yazdı:

Hi Sengul,



Your objective function needs to be a scalar. So you might try moving your 3nd right bracket way to the right, so that the entire term is summed over i and j.



Frank Ward



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of sengul can
Sent: Tuesday, March 01, 2016 6:07 AM
To: gamsworld
Subject: to write objective function



Hi,



my objective function as is follow;





ΣΣ𝐗𝐃𝐢,𝐤 + 𝐗𝐍𝐢,𝐤 + 𝐗𝐑𝐢,𝐤 for all i and k value



and my gams code as is follow;



Amac.. sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k) =e=z;



but this syntax has error. what is true sytax for this objective function?



sincerely..

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

--
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: to write objective function

Post by Archiver »


Hi Frank,

I'm grateful for your answer. I fix my objective function but now i have an error this line : solve nurseproblem minimizing z using MIP;

error: The symbol shown has been declared as an equation, but no symbolic equation (..) was found....

my gams code is as follow. can you help me again, please


sets
k hemÅŸire indisi /h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,12/
n gün sayısı /28/
m hemşire sayısı /12/
i gün indisi /n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28/
j vardiyalar /Di,Ni/
Di gündüz vardiyası hemşire sayısı /5/
Ni gece vardiyasındaki hemşire sayısı /3/
h hatasonu günleri /6,7,13,14,20,21,27,28/

variables
XD(i,k)
XN(i,k)
XR(i,k)
z;

equations
Sbt1
Sbt11
Sbt2
Sbt3
Sbt4
DKisit1
DKisit2
DKisit3
DKisit33
DKisit4
DKisit5
DKisit6
DKisit66
DKisit7
DKisit8
DKisit88
DKisit9
Yedek
Amac;


Sbt1.. sum((i,k),XD(i,k)) =g= 5;
Sbt11.. sum((i,k),XD(i,k)) =g= 3;
Sbt2(i,k).. XD(i,k) + XN(i,k) + XR(i,k) =l=1;
Sbt3(i,k).. XD(i+1,k)+ XN(i,k) =e= 1;
Sbt4(i,k).. XN(i,k)+XN(i+1,k) =e= 1;
DKisit1(i,k)$(ord(i) eq 6 or ord(i) eq 7 or ord(i) eq 13 or ord(i) eq 14 or ord(i) eq 20 or ord(i) eq 21 or ord(i) eq 27 or ord(i) eq 28).. XR(i,k) =g= 4;
DKisit2(i,k)$(ord(i) eq 6 or ord(i) eq 13 or ord(i) eq 20 or ord(i) eq 27).. XR(i,k)+XR(i+1,k) =l= 1;
DKisit3(i,k).. XD(i,k)+XN(i,k) =g= 15;
DKisit33(i,k).. XD(i,k)+XN(i,k) =l= 18;
DKisit4.. sum((i,k),XD(i,k)) =g= 6;
DKisit5.. sum((i,k),XD(i,k)) - sum((i,k),XN(i,k)) =g= 0;
DKisit6.. sum((i,k)$(ord(k) eq 3 or ord(k) eq 4 or ord(k) eq 5 or ord(k) eq 6),XD(i,k)) =g= 1;
DKisit66.. sum((i,k)$(ord(k) eq 3 or ord(k) eq 4 or ord(k) eq 5 or ord(k) eq 6),XR(i,k)) =g= 1;
DKisit7(i,k)$(ord(k) eq 1 or ord(k) eq 2).. XD(i,k) + XR(i,k) =l= 28;
DKisit8.. sum((i,k)$(ord(k) eq 1),XN(i,k)) =e= 0;
DKisit88.. sum((i,k)$(ord(k) eq 2),XN(i,k)) =e= 0;
DKisit9(i,k).. XR(i,k) + XR(i+1,k) + XR(i+2,k) =l=2;
Amac.. sum((i,k), XD(i,k) + XN(i,k) + XR(i,k)) =e=z;

model nurseproblem /all/;
solve nurseproblem minimizing z using MIP;

2 Mart 2016 Çarşamba 09:36:37 UTC+2 tarihinde Frank Ward yazdı:

Try this. If it doesn’t work, please send me your GAMS code and I'll fix it. Frank



Amac.. sum((i,k), XD(i,k) + XN(i,k) + XR(i,k)) =e=z;







From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of sengul can
Sent: Tuesday, March 01, 2016 12:04 PM
To: gamsworld
Subject: Re: to write objective function



Hi Frank,



thank you for your answer.

i think i didn't understood very well.

after your suggestion my model is as follow;



Amac.. (sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k)) =e=z;



but still i have an error.





1 Mart 2016 Salı 16:36:18 UTC+2 tarihinde Frank Ward yazdı:

Hi Sengul,



Your objective function needs to be a scalar. So you might try moving your 3nd right bracket way to the right, so that the entire term is summed over i and j.



Frank Ward



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of sengul can
Sent: Tuesday, March 01, 2016 6:07 AM
To: gamsworld
Subject: to write objective function



Hi,



my objective function as is follow;





ΣΣ𝐗𝐃𝐢,𝐤 + 𝐗𝐍𝐢,𝐤 + 𝐗𝐑𝐢,𝐤 for all i and k value



and my gams code as is follow;



Amac.. sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k) =e=z;



but this syntax has error. what is true sytax for this objective function?



sincerely..

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

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

--
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: to write objective function

Post by Archiver »


Hi Frank,

i changed my solve line but still i have an error.
my error code: objective is not a variable

what is wrong this line?
can you tell me

model nurseproblem /all/;
solve nurseproblem using mip minimizing Amac;


sets
k hemÅŸire indisi /h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,12/
n gün sayısı /28/
m hemşire sayısı /12/
i gün indisi /n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28/
j vardiyalar /Di,Ni/
Di gündüz vardiyası hemşire sayısı /5/
Ni gece vardiyasındaki hemşire sayısı /3/
h hatasonu günleri /6,7,13,14,20,21,27,28/

variables
XD(i,k)
XN(i,k)
XR(i,k)
z;

equations
Sbt1
Sbt11
Sbt2
Sbt3
Sbt4
DKisit1
DKisit2
DKisit3
DKisit33
DKisit4
DKisit5
DKisit6
DKisit66
DKisit7
DKisit8
DKisit88
DKisit9
Yedek
Amac;

Amac.. z =e= sum((i,k), XD(i,k) + XN(i,k) + XR(i,k));
Sbt1.. sum((i,k),XD(i,k)) =g= 5;
Sbt11.. sum((i,k),XD(i,k)) =g= 3;
Sbt2(i,k).. XD(i,k) + XN(i,k) + XR(i,k) =l=1;
Sbt3(i,k).. XD(i+1,k)+ XN(i,k) =e= 1;
Sbt4(i,k).. XN(i,k)+XN(i+1,k) =e= 1;
DKisit1(i,k)$(ord(i) eq 6 or ord(i) eq 7 or ord(i) eq 13 or ord(i) eq 14 or ord(i) eq 20 or ord(i) eq 21 or ord(i) eq 27 or ord(i) eq 28).. XR(i,k) =g= 4;
DKisit2(i,k)$(ord(i) eq 6 or ord(i) eq 13 or ord(i) eq 20 or ord(i) eq 27).. XR(i,k)+XR(i+1,k) =l= 1;
DKisit3(i,k).. XD(i,k)+XN(i,k) =g= 15;
DKisit33(i,k).. XD(i,k)+XN(i,k) =l= 18;
DKisit4.. sum((i,k),XD(i,k)) =g= 6;
DKisit5.. sum((i,k),XD(i,k)) - sum((i,k),XN(i,k)) =g= 0;
DKisit6.. sum((i,k)$(ord(k) eq 3 or ord(k) eq 4 or ord(k) eq 5 or ord(k) eq 6),XD(i,k)) =g= 1;
DKisit66.. sum((i,k)$(ord(k) eq 3 or ord(k) eq 4 or ord(k) eq 5 or ord(k) eq 6),XR(i,k)) =g= 1;
DKisit7(i,k)$(ord(k) eq 1 or ord(k) eq 2).. XD(i,k) + XR(i,k) =l= 28;
DKisit8.. sum((i,k)$(ord(k) eq 1),XN(i,k)) =e= 0;
DKisit88.. sum((i,k)$(ord(k) eq 2),XN(i,k)) =e= 0;
DKisit9(i,k).. XR(i,k) + XR(i+1,k) + XR(i+2,k) =l=2;


model nurseproblem /all/;
solve nurseproblem using mip minimizing Amac;





2 Mart 2016 Çarşamba 09:36:37 UTC+2 tarihinde Frank Ward yazdı:

Try this. If it doesn’t work, please send me your GAMS code and I'll fix it. Frank



Amac.. sum((i,k), XD(i,k) + XN(i,k) + XR(i,k)) =e=z;







From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of sengul can
Sent: Tuesday, March 01, 2016 12:04 PM
To: gamsworld
Subject: Re: to write objective function



Hi Frank,



thank you for your answer.

i think i didn't understood very well.

after your suggestion my model is as follow;



Amac.. (sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k)) =e=z;



but still i have an error.





1 Mart 2016 Salı 16:36:18 UTC+2 tarihinde Frank Ward yazdı:

Hi Sengul,



Your objective function needs to be a scalar. So you might try moving your 3nd right bracket way to the right, so that the entire term is summed over i and j.



Frank Ward



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of sengul can
Sent: Tuesday, March 01, 2016 6:07 AM
To: gamsworld
Subject: to write objective function



Hi,



my objective function as is follow;





ΣΣ𝐗𝐃𝐢,𝐤 + 𝐗𝐍𝐢,𝐤 + 𝐗𝐑𝐢,𝐤 for all i and k value



and my gams code as is follow;



Amac.. sum(i, sum(k, XD(i,k))) + XN(i,k) + XR(i,k) =e=z;



but this syntax has error. what is true sytax for this objective function?



sincerely..

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

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

--
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Post Reply