#include <OSDipApp.h>
Collaboration diagram for OSDipApp:
Public Member Functions | |
void | initializeApp (UtilParameters &utilParam) |
Initialize application. | |
void | createModels () |
Create model parts. | |
void | createModelPart (DecompConstraintSet *model, const int nRowsPart, const int *rowsPart) |
int | generateInitVars (DecompVarList &initVars) |
void | createModelMasterOnlys2 (vector< int > &masterOnlyCols) |
DecompSolverStatus | solveRelaxed (const int whichBlock, const double *redCostX, const double convexDual, list< DecompVar * > &vars) |
Solve the relaxed problem. | |
int | generateCuts (const double *x, DecompCutList &newCuts) |
bool | APPisUserFeasible (const double *x, const int n_cols, const double tolZero) |
OSDipApp (UtilParameters &utilParam) | |
Default constructor. | |
virtual | ~OSDipApp () |
Public Attributes | |
OSDipFactoryInitializer * | factoryInit |
std::vector< OSDipBlockSolver * > | m_osDipBlockSolver |
m_osDipBlockSolver is a vector OSDipBlockSolvers | |
std::vector< OSInstance * > | m_blockOSInstances |
m_blockOSInstances is a vector with an osinstance for each block | |
std::vector< std::set< int > > | m_blockVars |
m_blockVars is a vector with the set of variables for each block | |
std::set< int > | m_blockVarsAll |
m_blockVarsAll is the set of all variables that appear in a block | |
std::set< int > | m_coreConstraintIndexes |
m_coreConstraintIndexes is the set core constraint indexes | |
std::vector< std::string > | m_blockFactories |
m_blockFactories is a vector solver factory for each block | |
const string | m_classTag |
Class id tag (for log / debugging). | |
OS_DipInterface | m_osInterface |
the OS interface | |
OSDipParam | m_appParam |
Application specific parameters. | |
double * | m_objective |
The model objective coefficients (original space). | |
DecompConstraintSet * | m_modelC |
The model constraint systems used for different algos. | |
map< int, DecompConstraintSet * > | m_modelR |
map< int, DecompConstraintSet * > | m_modelMasterOnly |
The model constraint system used master only vars. |
Definition at line 38 of file OSDipApp.h.
OSDipApp::OSDipApp | ( | UtilParameters & | utilParam | ) | [inline] |
Default constructor.
Takes an instance of UtilParameters
Definition at line 109 of file OSDipApp.h.
References initializeApp().
virtual OSDipApp::~OSDipApp | ( | ) | [inline, virtual] |
Definition at line 114 of file OSDipApp.h.
References factoryInit, m_modelC, m_modelMasterOnly, m_modelR, m_objective, and m_osDipBlockSolver.
void OSDipApp::initializeApp | ( | UtilParameters & | utilParam | ) |
Initialize application.
std::vector<std::set<int> >iterator vit2;
std::vector<IndexValuePair*> solIndexValPair; std::vector<IndexValuePair*>::iterator vit3; double optVal;
double *cost = NULL; int index; int whichBlock;
whichBlock = 0;
for (vit2 = m_blockVars.begin(); vit2 != m_blockVars.end(); vit2++) {
blockVar = *vit2;
cost = new double[blockVar.size()];
index = 0;
for (sit = blockVar.begin(); sit != blockVar.end(); sit++) {
cost[index] = m_objective[*sit]; cost[index] = -1; index++;
} solIndexValPair.clear(); m_osDipBlockSolver[whichBlock++]->solve(cost, &solIndexValPair, &optVal);
std::cout << "OPTIMAL VALUE = " << optVal << std::endl;
std::cout << "solIndexValPair SIZE 2 = " << solIndexValPair.size() << std::endl;
for (vit3 = solIndexValPair.begin(); vit3 != solIndexValPair.end(); vit3++) {
std::cout << "IDEXXXXX = " << (*vit3)->idx << std::endl; std::cout << "VALUEEEEE = " << (*vit3)->value << std::endl; }
delete[] cost;
}
Definition at line 23 of file OSDipApp.cpp.
References createModels(), OSDipParam::DataDir, OSDipParam::dumpSettings(), ErrorClass::errormsg, OSDipBlockSolverFactory::factories, factoryInit, OS_DipInterface::getBlockFactories(), OS_DipInterface::getBlockOSInstances(), OS_DipInterface::getBlockVarIndexes(), OS_DipInterface::getCoreConstraintIndexes(), OSDipParam::getSettings(), OSDipParam::LogLevel, m_appParam, m_blockFactories, m_blockOSInstances, m_blockVars, m_blockVarsAll, m_classTag, m_coreConstraintIndexes, m_osDipBlockSolver, m_osInterface, OS_DipInterface::m_osoption, OSDipBlockSolver::m_whichBlock, OSDipParam::OSiLFile, OSDipParam::OSoLFile, OS_DipInterface::readOSiL(), OS_DipInterface::readOSoL(), and OSDipParam::solverFactory.
Referenced by OSDipApp().
void OSDipApp::createModels | ( | ) |
Create model parts.
Definition at line 293 of file OSDipApp.cpp.
References createModelMasterOnlys2(), createModelPart(), ErrorClass::errormsg, OS_DipInterface::getObjectiveFunctionCoeff(), OS_DipInterface::getVariableNumber(), OSDipParam::LogLevel, m_appParam, m_blockVars, m_blockVarsAll, m_classTag, m_coreConstraintIndexes, m_modelC, m_objective, and m_osInterface.
Referenced by initializeApp().
void OSDipApp::createModelPart | ( | DecompConstraintSet * | model, | |
const int | nRowsPart, | |||
const int * | rowsPart | |||
) |
Definition at line 197 of file OSDipApp.cpp.
References OS_DipInterface::getColLower(), OS_DipInterface::getColUpper(), OS_DipInterface::getConstraintNames(), OS_DipInterface::getIntegerColumns(), OS_DipInterface::getRowLower(), OS_DipInterface::getRowUpper(), OS_DipInterface::getVariableNumber(), m_appParam, OS_DipInterface::m_coinpm, m_osInterface, r, and OSDipParam::UseNames.
Referenced by createModels().
int OSDipApp::generateInitVars | ( | DecompVarList & | initVars | ) |
Definition at line 457 of file OSDipApp.cpp.
References ErrorClass::errormsg, OSOption::getNumberOfOtherVariableOptions(), OSOption::getOtherVariableOptions(), OSDipParam::LogLevel, m_appParam, m_classTag, m_objective, m_osInterface, and OS_DipInterface::m_osoption.
void OSDipApp::createModelMasterOnlys2 | ( | vector< int > & | masterOnlyCols | ) |
Definition at line 404 of file OSDipApp.cpp.
References OSDipParam::ColumnLB, OSDipParam::ColumnUB, OS_DipInterface::getColLower(), OS_DipInterface::getColUpper(), OS_DipInterface::getIntegerColumns(), OS_DipInterface::getVariableNumber(), OSDipParam::LogLevel, m_appParam, m_blockVars, m_modelMasterOnly, and m_osInterface.
Referenced by createModels().
DecompSolverStatus OSDipApp::solveRelaxed | ( | const int | whichBlock, | |
const double * | redCostX, | |||
const double | convexDual, | |||
list< DecompVar * > & | vars | |||
) |
Solve the relaxed problem.
Definition at line 590 of file OSDipApp.cpp.
References ErrorClass::errormsg, OSDipParam::LogLevel, m_appParam, m_blockVars, m_classTag, m_objective, and m_osDipBlockSolver.
int OSDipApp::generateCuts | ( | const double * | x, | |
DecompCutList & | newCuts | |||
) |
Definition at line 709 of file OSDipApp.cpp.
bool OSDipApp::APPisUserFeasible | ( | const double * | x, | |
const int | n_cols, | |||
const double | tolZero | |||
) |
Definition at line 720 of file OSDipApp.cpp.
std::vector<OSDipBlockSolver* > OSDipApp::m_osDipBlockSolver |
m_osDipBlockSolver is a vector OSDipBlockSolvers
Definition at line 44 of file OSDipApp.h.
Referenced by initializeApp(), solveRelaxed(), and ~OSDipApp().
std::vector<OSInstance* > OSDipApp::m_blockOSInstances |
m_blockOSInstances is a vector with an osinstance for each block
Definition at line 47 of file OSDipApp.h.
Referenced by initializeApp().
std::vector<std::set<int> > OSDipApp::m_blockVars |
m_blockVars is a vector with the set of variables for each block
Definition at line 50 of file OSDipApp.h.
Referenced by createModelMasterOnlys2(), createModels(), initializeApp(), and solveRelaxed().
std::set<int> OSDipApp::m_blockVarsAll |
m_blockVarsAll is the set of all variables that appear in a block
Definition at line 53 of file OSDipApp.h.
Referenced by createModels(), and initializeApp().
std::set<int> OSDipApp::m_coreConstraintIndexes |
m_coreConstraintIndexes is the set core constraint indexes
Definition at line 56 of file OSDipApp.h.
Referenced by createModels(), and initializeApp().
std::vector<std::string > OSDipApp::m_blockFactories |
m_blockFactories is a vector solver factory for each block
Definition at line 59 of file OSDipApp.h.
Referenced by initializeApp().
const string OSDipApp::m_classTag |
Class id tag (for log / debugging).
Definition at line 62 of file OSDipApp.h.
Referenced by createModels(), generateInitVars(), initializeApp(), and solveRelaxed().
the OS interface
Definition at line 65 of file OSDipApp.h.
Referenced by createModelMasterOnlys2(), createModelPart(), createModels(), generateInitVars(), and initializeApp().
Application specific parameters.
Definition at line 68 of file OSDipApp.h.
Referenced by createModelMasterOnlys2(), createModelPart(), createModels(), generateInitVars(), initializeApp(), and solveRelaxed().
double* OSDipApp::m_objective |
The model objective coefficients (original space).
Definition at line 71 of file OSDipApp.h.
Referenced by createModels(), generateInitVars(), solveRelaxed(), and ~OSDipApp().
DecompConstraintSet* OSDipApp::m_modelC |
The model constraint systems used for different algos.
Definition at line 74 of file OSDipApp.h.
Referenced by createModels(), and ~OSDipApp().
map<int, DecompConstraintSet*> OSDipApp::m_modelR |
map<int, DecompConstraintSet*> OSDipApp::m_modelMasterOnly |
The model constraint system used master only vars.
Definition at line 78 of file OSDipApp.h.
Referenced by createModelMasterOnlys2(), and ~OSDipApp().