First Example

Below is our first CLP sample program. It is short enough to present in full (this code can be found in the CLP Samples directory, see Chapter 4, More Samples ). Most of the remaining examples in this Guide will take the form of small code fragments.

Example 2.1. minimum.cpp

// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.

#include "ClpSimplex.hpp"
int main (int argc, const char *argv[])
  ClpSimplex  model;
  int status;
  if (argc<2)
  if (!status) {
  return 0;

This sample program creates a ClpSimplex model, reads an MPS file, and if there are no errors, solves it using the primal algorithm. The program is easy to follow, but it is not terribly useful: it does not attempt to inspect the results of the solve. There are two main kinds of results: a "status" describing what happened to the model during the solve, and arrays filled with solution values. Both will be addressed in this chapter.