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.c

/********************************************************
BCL Example Problems
====================

file xbcoco1.c

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

(c) 2008 Fair Isaac Corporation
author: S.Heipcke, Jan. 2000, rev. Mar. 2011
********************************************************/

#include <stdio.h>
#include "xprb.h"

int main(int argc, char **argv)
{
XPRBvar make11,make21,make12,make22;
XPRBctr ctr;
XPRBprob prob;

prob=XPRBnewprob("Coco1");       /* Initialize a new problem in BCL */

/****VARIABLES****/
make11=XPRBnewvar(prob,XPRB_PL,"make11",0,XPRB_INFINITY);
/* Amount of prod. 1 to make at factory 1 */
make21=XPRBnewvar(prob,XPRB_PL,"make21",0,XPRB_INFINITY);
/* Amount of prod. 2 to make at factory 1 */
make12=XPRBnewvar(prob,XPRB_PL,"make12",0,XPRB_INFINITY);
/* Amount of prod. 1 to make at factory 2 */
make22=XPRBnewvar(prob,XPRB_PL,"make22",0,XPRB_INFINITY);
/* Amount of prod. 2 to make at factory 2 */
/****OBJECTIVE****/
ctr = XPRBnewctr(prob,"OBJ",XPRB_N);
XPRBaddterm(ctr, make11,  50);   /* Objective: maximize total profit */
XPRBsetobj(prob,ctr);            /* Select objective function */

/****CONSTRAINTS****/
ctr=XPRBnewctr(prob,"MxMake1",XPRB_L);  /* Capacity limit at factory 1 */

ctr=XPRBnewctr(prob,"MxMake2",XPRB_L);  /* Capacity limit at factory 2 */

ctr=XPRBnewctr(prob,"MxSell1",XPRB_L);  /* Limit on amount of prod. 1 to be sold */

ctr=XPRBnewctr(prob,"MxSell2",XPRB_L);  /* Limit on amount of prod. 2 to be sold */

/****SOLVING + OUTPUT****/
XPRBsetsense(prob, XPRB_MAXIM);      /* Choose the sense of optimization */
XPRBlpoptimize(prob, "");            /* Solve the LP-problem */
printf("Objective: %g\n", XPRBgetobjval(prob));   /* Get objective value */

/* Print out the solution values for all variables */
printf("%s: %g\n",XPRBgetvarname(make11),XPRBgetsol(make11));
printf("%s: %g\n",XPRBgetvarname(make21),XPRBgetsol(make21));
printf("%s: %g\n",XPRBgetvarname(make12),XPRBgetsol(make12));
printf("%s: %g\n",XPRBgetvarname(make22),XPRBgetsol(make22));

return 0;
}