/********************************************************
Xpress-BCL Java Example Problems
================================
file xbfixbvls.java
```````````````````
Using the complete Coco Problem, as in xbcoco.java
this program implements a binary fixing heuristic.
- Model version saving and loading a start solution -
(c) 2009 Fair Isaac Corporation
author: S.Heipcke, Oct. 2009, rev. Mar. 2011
********************************************************/
import com.dashoptimization.*;
public class xbfixbvls
{
static final double TOL = 5.0E-4;
static final int PHASE = 5;
/* Phase = 4: Mines may open/closed freely; when closed save 20000 per month
* Phase = 5: Once closed always closed; larger saving */
static final int NP = 2; /* Number of products (p) */
static final int NF = 2; /* factories (f) */
static final int NR = 2; /* raw materials (r) */
static final int NT = 4; /* time periods (t) */
/****DATA****/
static final double[][] REV =
{{400, 380, 405, 350},
{410, 397, 412, 397}};
/* Unit selling price of prod. p in period t */
static final double[][] CMAK =
{{150, 153},
{ 75, 68}}; /* Unit cost to make product p at factory f */
static final double[][] CBUY =
{{100, 98, 97, 100},
{200, 195, 198, 200}};
/* Unit cost to buy raw material r in period t */
static final double[] COPEN = {50000, 63000};
/* Fixed cost of factory f being open for one period */
static final double CPSTOCK = 2.0; /* Unit cost to store any product p */
static final double CRSTOCK = 1.0; /* Unit cost to store any raw material r */
static final double[][] REQ =
{{1.0, 0.5},
{1.3, 0.4}}; /* Requirement by unit of prod. p for raw material r */
static final double[][] MXSELL =
{{650, 600, 500, 400},
{600, 500, 300, 250}};
/* Max. amount of p that can be sold in period t */
static final double[] MXMAKE = {400, 500};
/* Max. amount factory f can make over all products */
static final double MXRSTOCK = 300;
/* Max. amount of r that can be stored each f and t */
static final double[][] PSTOCK0 =
{{50, 100},
{50, 50}}; /* Initial product p stock level at factory f */
static final double[][] RSTOCK0 =
{{100, 150},
{ 50, 100}}; /* Initial raw material r stock level at factory f*/
static XPRB bcl;
static XPRBprob pb;
static XPRBvar[][] openm;
/***********************************************************************/
static void modCoco() throws XPRSexception
{
XPRBvar[][][] make, sell, pstock, buy, rstock;
XPRBexpr lobj, lc;
int p,f,r,t;
bcl = new XPRB(); /* Initialize BCL */
pb = bcl.newProb("Coco"); /* Create a new problem in BCL */
XPRS.init(); /* Initialize Xpress-Optimizer */
/****VARIABLES****/
make = new XPRBvar[NP][NF][NT];
sell = new XPRBvar[NP][NF][NT];
pstock = new XPRBvar[NP][NF][NT+1];
buy = new XPRBvar[NR][NF][NT];
rstock = new XPRBvar[NR][NF][NT+1];
openm = new XPRBvar[NF][NT];
for(p=0;p