BlockIPPlatform
 All Classes Files Functions Variables
SMLBlockIP.h
Go to the documentation of this file.
1 
6 #ifndef SMLBlockIP_H
7 #define SMLBlockIP_H
8 
9 #include <string>
10 #include "ExpandedModelInterface.h"
11 #include "BlockIP.h"
12 #include "MatrixBlockIP.h"
13 
14 using namespace std;
15 
17 class SMLBlockIP {
18  private:
19  struct objBlock {
20  bool nonlinear;
21  int numVars;
22  int numQuadVars;
23  double *linearCoefs;
24  double *quadraticCoefs;
25  ExpandedModelInterface *model;
26  };
27 
28  struct objFunction {
29  int numBlocks;
30  bool slacks;
31  int *slacksOrder;
32  objBlock *blocks;
33  };
34 
35  struct Order_vector {
36  string* *v;
37  bool operator() (int i,int j) {
38  return (*v[i] < *v[j]);
39  }
40  };
41 
42  int numBlocks;
43  int numVars;
44  int numCons;
45  int numLinCons;
46  bool slacks;
47  bool nonLinear;
48  bool linear;
49  ExpandedModelInterface *root;
50  ExpandedModelInterface* slacksBlock;
53  string *blockNames;
54  string *varNames;
55  int *varsOrder;
56  string *consNames;
57 
61 
62  double inf;
63 
64  static void fobjnonlin(int n, double x[], double &fx, double Gx[], double Hx[], void *params);
65 
66  public:
67  // Constructor
68  SMLBlockIP();
69 
70  // Constructor
71  SMLBlockIP(ExpandedModelInterface *root);
72 
73  // Destructor
74  ~SMLBlockIP();
75 
76  // Load a problem from ampl files
77  void readAmpl(const char *modelFilename, const char *dataFilename);
78 
79  // Converts a problem in ampl format to mps format
80  void amplToMps(const char *modelFilename, const char *dataFilename, const char *mpsFilename, bool convertToStd=false);
81 
82  // Converts a problem in ampl format to BlockIP format
83  void amplToBlockIPFormat(const char *modelFilename, const char *dataFilename, const char *BlockIPFormatFilename, bool convertToStd=false);
84 
85  // Get BlockIP interface
86  BlockIP* getBlockIPInterface();
87 
88  // Print the whole problem through standard output
89  void printProblem();
90 
91  // Return true if the objective function is non-linear
92  bool isNonLinear();
93 
94  // Return true if the objective function is quadratic
95  bool isQuadratic();
96 
97  // Return the correct order of the variables, ampl change the order
98  const int* getVarsOrder();
99 
100  private:
101  void initialize();
102 
103  // Load a problem from SML structure to BlockIP
104  void loadProblemInBlockIP();
105 
106  void freeMemory();
107 };
108 
111 
114 {
115  return nonLinear;
116 }
117 
120 
123 {
124  return !linear && !nonLinear;
125 }
126 
127 inline const int* SMLBlockIP::getVarsOrder()
129 
132 {
133  return varsOrder;
134 }
135 
136 #endif //SMLBlockIP_H