Initializing help system before first use

Chess - Composing constraints and solving


Type: Production planning
Rating: 1 (simple)
Description: A tiny LP problem concerning the manufacture of chess boards. The example composes constraints term by term and then solves the problem.
File(s): xbchess.c


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 */
 XPRBaddterm(c, xl,20);
 XPRBsetobj(prob,c);             /* Select objective function */ 

/****CONSTRAINTS****/
                                 /* Define the constraint 3*xs + 2*xl <= 400 */
 c=XPRBnewctr(prob,"mc_time",XPRB_L); 
 XPRBaddterm(c,xs,3);
 XPRBaddterm(c,xl,2);
 XPRBaddterm(c,NULL,400);
                                 /* Define the constraint xs + 3*xl <= 200 */
 c=XPRBnewctr(prob,"wood",XPRB_L);
 XPRBaddterm(c,xs,1);
 XPRBaddterm(c,xl,3);
 XPRBaddterm(c,NULL,200);
  
/****SOLVING****/
 XPRBsetsense(prob, XPRB_MAXIM);
 XPRBlpoptimize(prob,"");        /* Solve the LP-problem */

 return 0;
}

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.