-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPLEXsolver.h
66 lines (53 loc) · 4.66 KB
/
CPLEXsolver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef CPLEXSOLVER_H_
#define CPLEXSOLVER_H_
#include "MPCsolver.h"
#include <string>
#include <ilcplex/ilocplexi.h>
class CPLEXsolver : public MPCsolver
{
public:
CPLEXsolver(const int numVariable, const int numIneqConstraint, const int numEqConstraint, const int numQIneqConstraint, const solverType solverMethod);
CPLEXsolver(const int numVariable, const int numIneqConstraint, const int numEqConstraint, const int numQIneqConstraint);
CPLEXsolver();
~CPLEXsolver();
bool initProblem();
bool setProblem(const Ref<const MatrixXd> hessian, const Ref<const VectorXd> gradient); // H, f
bool setProblem(const Ref<const MatrixXd> hessian, const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B); // H, f, Ain, Bin
bool setProblem(const Ref<const MatrixXd> hessian, const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B, // H, f, Ain, Bin, l, Q, r
const std::vector<VectorXd>& l, const std::vector<MatrixXd> Q, const std::vector<double>& r);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB. uB
const Ref<const VectorXd> gradient);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB, uB, l, Q, r
const Ref<const VectorXd> gradient, const std::vector<VectorXd>& l, const std::vector<MatrixXd> Q, const std::vector<double>& r);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB. uB, Ain, Bin
const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB. uB, Ain, Bin, l, Q, r
const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B,
const std::vector<VectorXd>& l, const std::vector<MatrixXd> Q, const std::vector<double>& r);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB. uB, Ain, Bin,
const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B, const Ref<const MatrixXd> Aeq, // Aeq, Beq
const Ref<const VectorXd> Beq);
bool setProblem(const std::vector<double>& lowerBound, const std::vector<double>& upperBound, const Ref<const MatrixXd> hessian, // H, f, lB. uB, Ain, Bin,
const Ref<const VectorXd> gradient, const Ref<const MatrixXd> A, const Ref<const VectorXd> B, const Ref<const MatrixXd> Aeq, // Aeq, Beq, l, Q, r
const Ref<const VectorXd> Beq, const std::vector<VectorXd>& l, const std::vector<MatrixXd> Q, const std::vector<double>& r);
bool solveProblem(Ref<VectorXd> result, int& optimizerStatus);
void saveProblem(const std::string filename);
void set_printLevel(const printLevelType printLevel);
void set_solverMethod(const solverType solverMethod) { _solverMethod = solverMethod; }
void set_solverParams(const double convergence_tolerance_QP, const double convergence_tolerance_QCP,
const double optimality_tolerance, const double feasibility_tolerance)
{ _convergenceTolQP = convergence_tolerance_QP; _convergenceTolQCP = convergence_tolerance_QCP;
_optimalityTol = optimality_tolerance; _feasibilityTol = feasibility_tolerance; }
solverType get_solverMethod() { return _solverMethod; }
private:
solverType _solverMethod;
bool _IloInitialized;
IloEnv _IloEnv; /** Ilo environment */
IloModel _IloModel; /** Ilo model */
IloNumVarArray _IloVar; /** Ilo unknowns */
IloRangeArray _IloConstrEq; /** Ilo inequality constraints */
IloRangeArray _IloConstrIneq; /** Ilo inequality constraints */
IloObjective _IloObj; /** Ilo objective function */
IloCplex _IloCplex; /** Cplex environment */
};
#endif /* CPLEXSOLVER_H_ */