/********************************************************
Xpress-BCL Java Example Problems
================================
file xbchess.java
`````````````````
Small LP-problem.
(c) 2008 Fair Isaac Corporation
author: S.Heipcke, Jan. 2000, rev. Mar. 2011
********************************************************/
import com.dashoptimization.*;
public class xbchess {
public static void main(String[] args) {
XPRBvar xs; /* Number of small chess sets to make */
XPRBvar xl; /* Number of large chess sets to make */
try (XPRBprob p = new XPRBprob("Chess")) { /* Initialize BCL and create a new problem */
/****VARIABLES****/
xs = p.newVar("xs");
xl = p.newVar("xl");
/****OBJECTIVE****/
p.setObj(xs.mul(5).add(xl.mul(20)));
/* Define & set the obj. function 5*xs + 20*xl */
/****CONSTRAINTS****/
/* Define the constraint 3*xs + 2*xl <= 400 */
p.newCtr("mc_time", xs.mul(3).add(xl.mul(2)).lEql(400) );
/* Define the constraint xs + 3*xl <= 200 */
p.newCtr("wood", xs.add(xl.mul(3)).lEql(200) );
/****SOLVING****/
p.setSense(XPRB.MAXIM);
p.lpOptimize(""); /* Solve the LP-problem */
}
}
}