set PRODUCTS; set MACHINES; param T > 0; # number of months in model param profit {PRODUCTS} >= 0; # profit on sale of an item of a product param time_used {PRODUCTS, MACHINES} >= 0; # amount of time on a machine # required to produce a product param number_machine {MACHINES} > 0; # number of machines of each type param number_repair {MACHINES, 1..T} >= 0; # number of machines of each type # under repair in a given month param market_limit {PRODUCTS, 1..T} >= 0; # marketing limitations on the products param require {PRODUCTS} >= 0; # number of products needed on hand at end of month T var sell {i in PRODUCTS, t in 1..T} >= 0, <= market_limit[i,t]; # number of products sold var store {i in PRODUCTS, t in 1..T} >= 0 <= 100; # number of products stored var produce {i in PRODUCTS, t in 1..T} >= 0; # number of products produced var machine_up {j in MACHINES, t in 1..T} >= 0, <= number_machine[j]; # number of machines working in a particular month maximize total_profit : sum{i in PRODUCTS} profit[i]*(sum{t in 1..T} sell[i,t]) # profit from selling products - 0.5*sum{i in PRODUCTS, t in 1..T} store[i,t]; subject to machine_capacity {j in MACHINES, t in 1..T}: sum{i in PRODUCTS} time_used[i,j] * produce[i,t] <= 24 * 16 * machine_up[j,t]; # limit on the amount of time that can be spent on a particular machine # in a particular month subject to inventory {i in PRODUCTS, t in 2..T}: store[i,t-1] + produce[i,t] = sell[i,t] + store[i,t]; # ensure that inventory is correctly calculated from month to month subject to inventory_month1 {i in PRODUCTS}: produce[i,1] = sell[i,1] + store[i,1]; # have no inventory on hand initially, so deal with the initial conditions subject to meet_final_demand {i in PRODUCTS}: store[i,T] >= require[i]; # meet the final demand subject to machines_available {j in MACHINES, t in 1..T}: machine_up[j,t] = number_machine[j] - number_repair[j,t]; # calculate the number of machines available in a given month