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 "mulprod" DIRSEP "mulprod.mod");
36:         IloOplSettings settings(env,handler);
37:         IloOplModelDefinition def(modelSource,settings);
38:         IloCplex cplex(env);
39:         IloOplModel opl(def,cplex);
40:         IloOplDataSource dataSource(env, DATADIR "mulprod" DIRSEP "mulprod.dat");
41:         opl.addDataSource(dataSource);
42:         opl.generate();
43: 
44:         if ( cplex.solve() ) {
45:           cout << endl
46:                 << "OBJECTIVE: " << fixed << setprecision(2) << opl.getCplex().getObjValue()
47:                 << endl;
48:             opl.postProcess();
49:             opl.printSolution(cout);
50:             status = 0;
51:         } else {
52:             cout << "No solution!" << endl;
53:             status = 1;
54:         }
55:     } catch (IloOplException & e) {
56:         cout << "### OPL exception: " << e.getMessage() << endl;
57:     } catch( IloException & e ) {
58:         cout << "### CONCERT exception: ";
59:         e.print(cout);
60:         status = 2;
61:     } catch (...) {
62:         cout << "### UNEXPECTED ERROR ..." << endl;
63:         status = 3;
64:     }
65: 
66:     env.end();
67: 
68:     cout << endl << "--Press <Enter> to exit--" << endl;
69:     getchar();
70: 
71:     return status;
72: }