| |||||||||||||||
Indicator and logic constraints Description Examples of formulating linear and nonlinear indicator constraints with Mosel, and of formulating logic constraints for MIP models using the Mosel module 'advmod'. Further explanation of this example: Whitepaper 'MIP formulations and linearizations', Sections 'Indicator constraints' and 'Logic constructs'
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
indicatornl.mos (!****************************************************** Mosel Example Problems ====================== file indicatornl.mos ```````````````````` Indicator constraint definition with NL constraints - Example discussed in mipformref whitepaper - (c) 2023 Fair Isaac Corporation author: S. Heipcke, Aug. 2023, rev. Feb. 2024 *******************************************************!) model "test NL indicator constraints" uses "mmxnlp" public declarations R=1..2 C: array(range) of nlctr L: array(range) of logctr x: array(R) of mpvar b: array(R) of mpvar end-declarations forall(i in R) b(i) is_binary ! Variables for indicator constraints C(2):= sin(x(2))>=0.5 ! Define 2 indicator constraints L(1):= indicator(1, b(1), x(1)*x(2)=12) ! b(1)=1 -> x(1)*x(2)=12 L(2):= indicator(-1, b(2), C(2)) ! b(2)=0 -> sin(x(2))>=0.5 C(2):=0 ! Delete auxiliary constraint definition Obj:= b(1)+b(2) setparam("XPRS_loadnames", true) loadprob(Obj) writeprob("logtestnlmat.lp","l") ! maximize(Obj) minimize(Obj) declarations status:array({XPRS_OPT,XPRS_UNF,XPRS_INF,XPRS_UNB,XPRS_OTH}) of string end-declarations status::([XPRS_OPT,XPRS_UNF,XPRS_INF,XPRS_UNB,XPRS_OTH])[ "Optimum found","Unfinished","Infeasible","Unbounded","Failed"] writeln("Problem status: ", status(getprobstat)) forall(i in R) writeln(x(i).name, "=", x(i).sol) forall(i in R) writeln(L(i).name, ": ", L(i).var.name, "=", L(i).var.sol, " ", L(i).indictype) end-model | |||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |