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

Chess - Composing constraints and solving

Description
A tiny LP problem concerning the manufacture of chess boards. The example composes constraints term by term and then solves the problem.

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

xbchess.c

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

file xbchess.c

Small LP-problem.

(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 xs;                     /* Number of small chess sets to make */
XPRBvar xl;                     /* Number of large chess sets to make */
XPRBctr c;
XPRBprob prob;

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

/****VARIABLES****/
xs = XPRBnewvar(prob,XPRB_PL,"xs",0,XPRB_INFINITY);
xl = XPRBnewvar(prob,XPRB_PL,"xl",0,XPRB_INFINITY);

/****OBJECTIVE****/
c = XPRBnewctr(prob,"OBJ",XPRB_N);
XPRBaddterm(c, xs,5);           /* Define the objective function */
XPRBsetobj(prob,c);             /* Select objective function */

/****CONSTRAINTS****/
/* Define the constraint 3*xs + 2*xl <= 400 */
c=XPRBnewctr(prob,"mc_time",XPRB_L);
/* Define the constraint xs + 3*xl <= 200 */
c=XPRBnewctr(prob,"wood",XPRB_L);