// -------------------------------------------------------------- -*- C++ -*-
// File: examples/src/ilomipex2.cpp
// Version 8.1
// --------------------------------------------------------------------------
// Copyright (C) 1999-2002 by ILOG.
// All Rights Reserved.
// Permission is expressly granted to use this example in the
// course of developing applications that use ILOG products.
// --------------------------------------------------------------------------
//
// ilomipex2.cpp - Reading in and optimizing a problem
//
// To run this example, command line arguments are required.
// i.e., ilomipex2 filename
//
// Example:
// ilomipex2 mexample.mps
//
#include <ilcplex/ilocplex.h>
ILOSTLBEGIN
static void usage (const char *progname);
int
main (int argc, char **argv)
{
IloEnv env;
try {
IloModel model(env);
IloCplex cplex(env);
if ( argc != 2 ) {
usage (argv[0]);
throw(-1);
}
IloObjective obj;
IloNumVarArray var(env);
IloRangeArray rng(env);
cplex.importModel(model, argv[1], obj, var, rng);
cplex.extract(model);
cplex.solve();
env.out() << "Solution status = " << cplex.getStatus() << endl;
env.out() << "Solution value = " << cplex.getObjValue() << endl;
IloNumArray vals(env);
cplex.getValues(vals, var);
env.out() << "Values = " << vals << endl;
}
catch (IloException& e) {
cerr << "Concert exception caught: " << e << endl;
}
catch (...) {
cerr << "Unknown exception caught" << endl;
}
env.end();
return 0;
} // END main
static void usage (const char *progname)
{
cerr << "Usage: " << progname << " filename" << endl;
cerr << " where filename is a file with extension " << endl;
cerr << " MPS, SAV, or LP (lower case is allowed)" << endl;
cerr << " Exiting..." << endl;
} // END usage
|