FICO Xpress Optimization Examples Repository
 FICO Optimization Community FICO Xpress Optimization Home

Coco - A full production planning example

Description
The Coco productional planning problem: multi-item, multi-period, multi-site production planning. A sequence of model versions show how the model was developed, to (a) use more sophisticated modeling features and (b) to extend the model, taking it from a simple linear model to one with fixed prices and logical decisions.
1. xbcoco1: initial formulation, data, variables and constraints fixed
2. xbcoco2: use parameters, data tables and subscripted variables.

read data tables in from text data files (short-term planning).
3. xbcoco3: like xbcoco2.c, but several time periods (mid-term planning).
4. xbcoco : complete problem, data defined in the model definition (long-term planning).

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.

Data Files

xbcoco1.cs

/********************************************************
Xpress-BCL C# Example Problems
==============================

file xbcoco1.cs

Coco Problem Phase 1.
Initial formulation: data, variables and
constraints fixed.

(c) 2008 Fair Isaac Corporation
authors: S.Heipcke, D.Brett.
********************************************************/

using System;
using System.Text;
using System.IO;
using BCL;

namespace Examples
{
public class TestCoco1
{
public static void Main()
{
XPRB.init();
XPRBvar make11,make21,make12,make22;
XPRBprob p = new XPRBprob("Coco1");         /* Initialize a new problem in BCL */

/****VARIABLES****/
make11 = p.newVar("make11"); /* Amount of prod. 1 to make at factory 1 */
make21 = p.newVar("make21"); /* Amount of prod. 2 to make at factory 1 */
make12 = p.newVar("make12"); /* Amount of prod. 1 to make at factory 2 */
make22 = p.newVar("make22"); /* Amount of prod. 2 to make at factory 2 */

/****OBJECTIVE****/
/* Define & set objective function: maximize total profit */
p.setObj(p.newCtr("OBJ", 50*make11 + 125*make21 + 47*make12 + 132*make22));

/****CONSTRAINTS****/
p.newCtr("MxMake1", make11+make21 <= 400);  /* Capacity limit at factory 1 */

p.newCtr("MxMake2", make12+make22 <= 500);  /* Capacity limit at factory 2 */

p.newCtr("MxSell1", make11+make12 <= 650);  /* Limit on the amount of
prod. 1 to be sold */

p.newCtr("MxSell2", make21+make22 <= 600);  /* Limit on the amount of
prod. 2 to be sold */

/****SOLVING + OUTPUT****/
p.setSense(BCLconstant.XPRB_MAXIM);      /* Choose the sense of the optimization */
p.lpOptimize();                 /* Solve the LP-problem */
System.Console.WriteLine("Objective: " + p.getObjVal());   /* Get objective value */

/* Print out the solution values for all variables */
System.Console.WriteLine(make11.getName() + ": " + make11.getSol());
System.Console.WriteLine(make21.getName() + ": " + make21.getSol());
System.Console.WriteLine(make12.getName() + ": " + make12.getSol());
System.Console.WriteLine(make22.getName() + ": " + make22.getSol());

return;
}

}

}
`