01: // -------------------------------------------------------------- -*- C++ -*-
02: // File: mulprod.cpp
03: // --------------------------------------------------------------------------
04: // Licensed Materials - Property of IBM
05: // 
06: // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 
07: // Copyright IBM Corporation 1998, 2013. All Rights Reserved.
08: //
09: // Note to U.S. Government Users Restricted Rights:
10: // Use, duplication or disclosure restricted by GSA ADP Schedule
11: // Contract with IBM Corp.
12: /////////////////////////////////////////////////////////////////////////////// 
13: 
14: #include <ilopl/iloopl.h>
15: 
16: #include <sstream>
17: 
18: #ifdef ILO_WINDOWS
19: #define DIRSEP "\\"
20: #else
21: #define DIRSEP "/"
22: #endif
23: #ifndef DATADIR
24: #define DATADIR ".." DIRSEP ".."  DIRSEP ".." DIRSEP ".." DIRSEP "opl" DIRSEP
25: #endif
26: 
27: ILOSTLBEGIN
28: 
29: int main(int argc,char* argv[]) {
30:     IloEnv env;
31: 
32:     int status = 127;
33:     try {
34:         IloOplErrorHandler handler(env,cout);
35:         IloOplModelSource modelSource(env, DATADIR "distMIP" DIRSEP "lifegameip.mod");
36:         IloOplSettings settings(env,handler);
37:         IloOplModelDefinition def(modelSource,settings);
38:         IloCplex cplex(env);
39:                 cplex.readVMConfig(DATADIR "distMIP" DIRSEP "process.vmc");
40:         IloOplModel opl(def,cplex);
41:         opl.generate();
42:                 cplex.solve();
43:         cout << endl
44:                 << "OBJECTIVE: " << fixed << setprecision(2) << opl.getCplex().getObjValue()
45:         << endl;
46:         opl.postProcess();
47:         opl.printSolution(cout);
48:         if (cplex.hasVMConfig())
49:                         cout << "cplex has a VM file" << endl;
50:                 else
51:                         throw IloWrongUsage("cplex does not have a VM file");
52:                 cplex.delVMConfig();
53:                 if (cplex.hasVMConfig())
54:                         throw IloWrongUsage("cplex has a VM file");
55:                 else
56:                         cout <<  "cplex does not have a VM file anymore" << endl;
57:                 status = 0;
58:     } catch (IloOplException & e) {
59:         cout << "### OPL exception: " << e.getMessage() << endl;
60:     } catch( IloException & e ) {
61:         cout << "### CONCERT exception: ";
62:         e.print(cout);
63:         status = 2;
64:     } catch (...) {
65:         cout << "### UNEXPECTED ERROR ..." << endl;
66:         status = 3;
67:     }
68: 
69:     env.end();
70: 
71:     cout << endl << "--Press <Enter> to exit--" << endl;
72:     getchar();
73: 
74:     return status;
75: }