Hello everyone,
I’m new to Julia, and I´m helping my wife with her Master degree. Unfortunately, we both lack a solid mathematical foundation, and that´s really making things more difficult for me.
I have started with the “Julia Programming for Operations Research - A Primer on Computing” book, from Changhyun Kwon (http://juliabook.chkwon.net/), and I am also trying to model some known problems to get a deeper understanding of the language.
I´ve been trying to model the problem below without success. Could you please give me a clue on that?
Thanks in advance!!
Best Regards,
GB
The stock problem
Month | 1 | 2 | 3 | 4 | 5 | 6 |
±----±----±----±----±----±----+
Demand | 50 | 100 | 30 | 80 | 110 | 60 |
P.Cost | 200 | 220 | 250 | 250 | 240 | 255 |
Maximum production per month: 70
Production w/ extra hour: +70 (+15% cost)
Monthly stock cost: 10,00 (per item)
x[n] = items produced using standard work hours
y[n] = items prodeced using extra hours
e[n] = items in stock (e[1] = 0)
Objective function:
Z min = (200 * x1) + (1.15 * 200 * y1) + (10 * e1)
(220 * x2) + (1.15 * 220 * y2) + (10 * e2)
(250 * x3) + (1.15 * 250 * y3) + (10 * e3)
(250 * x4) + (1.15 * 250 * y4) + (10 * e4)
(240 * x5) + (1.15 * 240 * y5) + (10 * e5)
(255 * x6) + (1.15 * 255 * y6) + (10 * e6)
Constraints:
x[n], y[n] >= 0, Int
e[n] >= 0, Int
x[n], y[n] <= 70
x[1] + y[1] + e[1] >= 50
x[2] + y[2] + e[2] >= 100
x[3] + y[3] + e[3] >= 30
x[4] + y[4] + e[4] >= 80
x[5] + y[5] + e[5] >= 110
x[6] + y[6] + e[6] = 60
e[n] + x[n] + y[n] - demand[n] = e[n+1]
What I´ve been trying…
using JuMP, Cbc
# Prepare the optimization model
m = Model(solver=CbcSolver())
# Problem data
demand = [50; 100; 30; 80; 110; 60]
cost = [200; 220; 250; 250; 240; 255]
# Variables
@variable(m, x[1:6] >=0, Int)
@variable(m, y[1:6] >=0, Int)
@variable(m, stock[1:6] >=0, Int)
# Objective function
@objective(m, Min, (x[n]*cost[n]) + (y[n]*cost[n]*1.15) + (stock[n]*10) = demand[n] for n = 1:6)
The result
syntax: "*(x[n],cost[n])" is not a valid function argument name