Integer Programming entities in Mosel
Definition: integer programming types are defined as unary constraints on previously declared decision variables of type mpvar; name the constraints if you want to be able to access/modify them.
declarations d: mpvar ifmake: array(PRODS,LINES) of mpvar x: mpvar end-declarations d is_binary ! Single binary variable forall(p in PRODS, l in LINES) ifmake(p,l) is_binary ! An array of binaries ACtr:= x is_integer ! An integer variable x >= MINVAL ! Lower bound on the variable x <= MAXVAL ! Upper bound on the variable ! MINVAL,MAXVAL: values between -MAX_REAL and MAX_REAL ... ACtr:= x is_partint 10 ! Change type to partial integer ... ACtr:= 0 ! Delete constraint ! Equivalently: ACtr:= x is_continuous ! Change type to continuous
Solving: with Xpress Optimizer (Mosel module mmxprs) any problem containing integer programming entities is automatically solved as a MIP problem, to solve just the LP relaxation use option XPRS_LPSTOP (if following up with MIP search) or XPRS_LIN (ignore all MIP information) for maximize / minimize.
Accessing the solution: for obtaining solution values of decision variables and linear expressions use getsol (alternative syntax: .sol); the MIP problem status is returned by the function getparam("XPRS_MIPSTATUS")
case getparam("XPRS_MIPSTATUS") of XPRS_MIP_NOT_LOADED, XPRS_MIP_LP_NOT_OPTIMAL: writeln("Solving not started") XPRS_MIP_LP_OPTIMAL: writeln("Root LP solved") XPRS_MIP_UNBOUNDED: writeln("LP unbounded") XPRS_MIP_NO_SOL_FOUND, XPRS_MIP_INFEAS: writeln("MIP search started, no solution") XPRS_MIP_SOLUTION, XPRS_MIP_OPTIMAL: writeln("MIP solution: ", , getobjval) end-case writeln("x: ", getsol(x)) writeln("d: ", d.sol)