分支定界法基本框架
This commit is contained in:
@ -3,31 +3,59 @@
|
||||
|
||||
namespace sv {
|
||||
|
||||
class Model
|
||||
{
|
||||
class LinSolver {
|
||||
public:
|
||||
Model();
|
||||
Var* addVars(int col);
|
||||
friend class Model;
|
||||
LinSolver();
|
||||
~LinSolver();
|
||||
|
||||
LinSolver(const LinSolver& solver);
|
||||
LinSolver& operator=(const LinSolver& solver);
|
||||
|
||||
Var* addVars(int col, VarType type);
|
||||
const Var& getVar(int idx);
|
||||
void addConstr(const Expr& expr, ConstrOper sense, double rhs);
|
||||
void setObjective(Expr obje, int sense = MDL_MAXIMIZE);
|
||||
void print();
|
||||
rtn optimize();
|
||||
|
||||
double get(DoubleAttr attr);
|
||||
int get(IntAttr attr);
|
||||
private:
|
||||
|
||||
rtn optimize();
|
||||
protected:
|
||||
|
||||
double _simplex();
|
||||
rtn _pivot(std::pair<size_t, size_t>& p);
|
||||
rtn feasible_solution();
|
||||
void _gaussian(std::pair<size_t, size_t> p);
|
||||
|
||||
Var* vars;
|
||||
|
||||
matrix mt;
|
||||
matrix mt_cvt;
|
||||
size_t cn, bn;
|
||||
std::vector<int> basic;
|
||||
rtn rtn_;
|
||||
double res_;
|
||||
double obj_;
|
||||
int sense;
|
||||
};
|
||||
|
||||
class Model
|
||||
{
|
||||
public:
|
||||
Model();
|
||||
rtn optimize();
|
||||
|
||||
Var* addVars(int col, VarType type);
|
||||
void addConstr(const Expr& expr, ConstrOper sense, double rhs);
|
||||
void setObjective(Expr obje, int sense = MDL_MAXIMIZE);
|
||||
|
||||
double get(DoubleAttr attr);
|
||||
int get(IntAttr attr);
|
||||
|
||||
private:
|
||||
LinSolver solver;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user