FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserNext example

Chess - Composing constraints and solving

A tiny LP problem concerning the manufacture of chess boards. The example composes constraints term by term and then solves the problem.[download all files]

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


  Xpress-BCL C++ Example Problems

  file xbchess.cxx
  Small LP-problem.

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

#include <iostream>
#include "xprb_cpp.h"

using namespace std;
using namespace ::dashoptimization;


int main(int argc, char **argv)
 XPRBvar xs;               /* Number of small chess sets to make */
 XPRBvar xl;               /* Number of large chess sets to make */
 XPRBprob p("Chess");      /* Initialize a new problem in BCL */

 xs = p.newVar("xs");
 xl = p.newVar("xl");
 p.setObj(p.newCtr("OBJ", 5*xs + 20*xl)); /* Define & set the obj. function */ 

                           /* Define the constraint 3*xs + 2*xl <= 400 */
 p.newCtr("mc_time", 3*xs + 2*xl <= 400);

                           /* Define the constraint xs + 3*xl <= 200 */
 p.newCtr("wood", xs + 3*xl <= 200);
 p.lpOptimize("");         /* Solve the LP-problem */

 return 0;

Back to examples browserNext example