Reply-to: gamsworld@googlegroups.com
Hi Arne,
Thanks! It woks when I use integer variable change the model to MIP!
Greetings!
Jarek
On Tuesday, 21 January 2014 14:23:37 UTC+1, Arne Stolbjerg Drud wrote:
Jarek
You should introduce an integer variable that defines the number of batches you are going to produce. You production is then number of batches times batch size,
With an integer variable your model becomes a MIP model instead of LP.
Good luck
Arne
\
Arne Stolbjerg Drud
ARKI Consulting & Development A/S
Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark
Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: ad…@arki.dk
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Jarek
Sent: Tuesday, January 21, 2014 11:21 AM
To: gams...@googlegroups.com
Subject: Re: Constraint checking if sum of variables is a whole number. Help please.
Hi Renger,
Thanks for your reply.
I think the mod function is for dividing and calculating the divisive reminder: mod(arg1, arg2)
The error is:
**** $51,256
**** The following LP errors were detected in model Production:
**** 51 equation batch… the function MOD is called with non-constant arguments
In short there are 4 producers making 4 products. Costs and production times differ for them.
They can make particular products only in batches (products KO : 100, SP: 20, BL: 30, SU: 20).
I need to find optimal production plan for maximizing net profit.
I have problem with the batches restriction.
Maybe what I’m trying to do makes no sense at all…
Here is the program:
$Ontext
$Offtext
Sets
i products / KO, SP, BL, SU /
j producers / S1, S2, S3, S4 / ;
Parameters
d(i) Demand
/ KO 2400
SP 1200
BL 1400
SU 800 /
p(i) Price
/ KO 220
SP 800
BL 530
SU 1050 /
w(j) Available time of work for producers
/ S1 160
S2 160
S3 160
S4 160 /
b(i) Batches in which products must be produced
/ KO 100
SP 20
BL 30
SU 20 / ;
Table c(i,j) production costs: dollars per item per producer
S1 S2 S3 S4
KO 11.5 11.8 11.7 11.6
SP 36 35 37.5 36
BL 22.3 23 21.7 24
SU 35 40 40 32.5 ;
Table pf(i,j) performance: items per hour per producer
S1 S2 S3 S4
KO 20 16 18 19
SP 5 6 4 5
BL 7 6 8 5
SU 3 2 2 4 ;
Scalar tf tax factor /0.81/ ;
Variables
x(i,j) items produced
np net profit;
Positive Variable x(i,j) ;
Equations
profit the objective function
workTime(j) time of work per month
demand(i) demand for the items
batch(i) constraints because of the batches ;
profit … np =e= sum((i,j), x(i,j)*(p(i)-c(i,j))*tf) ;
workTime(j) … sum(i, (1/pf(i,j))*x(i,j)) =l= w(j) ;
demand(i) … sum(j, x(i,j)) =l= d(i) ;
batch(i) … mod(sum(j, x(i,j)), b(i)) =e= 0 ;
Model Production /all/
solve Production maximazing np using LP
display x.l
On Tuesday, 21 January 2014 08:52:07 UTC+1, Renger van Nieuwkoop wrote:
Hi Jarek
It would be useful, if you would report the error message. In your code example below, you do not divide by pk(i) (“,†instead of “/â€)
Cheers
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Jarek
Sent: Dienstag, 21. Januar 2014 00:03
To: gams...@googlegroups.com
Subject: Constraint checking if sum of variables is a whole number. Help please.
Hi Guys,
Please help. I’m desperate now. I’m writing short optimization program in GAMS as an assignment on my university and I’m running out of time.
I need to define constraint saying that sum of computed values of variables devided by some specific factor is a whole number.
i.e:
10/2 = 5 which is ok
3/2 = 1.5 which is not ok
I tried to use mod() function to check the reminder but it returnes error.
Something like that:
packet(i) … mod(sum(j, x(i,j)), pk(i)) =e= 0;
x(i,j) is the variable
pk(i) is the divisive factor
The constraint should be that the value of the computation is equal to 0 (which means the number is whole): … =e= 0
How can I do it properly?
Thanks!
Jarek
\
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 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.
–
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.