(!****************************************************** Mosel User Guide Example Problems ================================= file initeval2s.mos ``````````````````` Initializations with evaluation. - Using arrays, string indices - (c) 2008 Fair Isaac Corporation author: S. Heipcke, Sep. 2007, rev. Jan. 2010 *******************************************************!) model "Evaluations 2s" uses "mmxprs" declarations PRODS = {"small", "large"} ! Index set DUR, WOOD, PROFIT: array(PRODS) of real ! Coefficients x: array(PRODS) of mpvar ! Array of variables end-declarations ! Function returning solution values as an array function solx:array(PRODS) of real forall(i in PRODS) returned(i):=x(i).sol end-function DUR :: (["small","large"])[3, 2] ! Initialize data arrays WOOD :: (["small","large"])[1, 3] PROFIT:: (["small","large"])[5, 20] ! Constraint definition Lathe:= sum(i in PRODS) DUR(i)*x(i) <= 160 Boxwood:= sum(i in PRODS) WOOD(i)*x(i) <= 200 forall(i in PRODS) x(i) is_integer maximize(sum(i in PRODS) PROFIT(i)*x(i)) initializations to "chessout.dat" evaluation of getobjval as "Objective" evaluation of Lathe.slack as "Spare time" evaluation of Boxwood.act as "Used wood" evaluation of Boxwood.act-200 as "Spare wood" evaluation of solx as "x_sol" evaluation of array(i in PRODS) x(i).sol as "x_sol_alt" end-initializations writeln("Solution: ", getobjval) ! Print objective function value writeln("x: ", solx) ! Print solution values writeln("Time: ", getact(Lathe), " ", getslack(Lathe)) writeln("Wood: ", Boxwood.sol, " ", Boxwood.act, " ", Boxwood.slack) end-model