28 #include <CoinHelperFunctions.hpp>
29 #include <CoinFileIO.hpp>
30 #include <OsiClpSolverInterface.hpp>
45 int main(
int argc,
char* argv[]) {
46 WindowsErrorPopupBlocker();
49 std::cout <<
"Call bcp_main " << std::endl;
50 retCode =
bcp_main(argc, argv, &os_init);
51 std::cout <<
"Return from call to bcp_main " << retCode << std::endl;
53 std::cout <<
"OSBranchCutPrice terminates normally" << std::endl;
73 const char dirsep = CoinFindDirSeparator();
76 dataDir = dirsep ==
'/' ?
"../data/" :
"..\\data\\";
77 cout <<
"Start Building the Model" << endl;
81 std::string osilFileName;
83 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0033.osil";
84 std::cout <<
"Try to read a sample file" << std::endl;
85 std::cout <<
"The file is: " << osilFileName << std::endl <<std::endl ;
90 os_prob.osinstance = os_prob.osilreader->readOSiL( osil);
97 std::cout << eclass.
errormsg << std::endl;
129 std::cout <<
"INITIALIZE THE CORE " << std::endl;
131 int num_vars = os_prob.osinstance->getVariableNumber();
134 objsign = ( os_prob.osinstance->getObjectiveMaxOrMins()[0] ==
"min") ? 1 : -1;
136 for (i = 0; i < num_vars; ++i) {
137 os_prob.osinstance->getDenseObjectiveCoefficients()[0][i] = objsign*(os_prob.osinstance->getDenseObjectiveCoefficients()[0][i]);
138 if ( os_prob.osinstance->getVariableTypes()[i] ==
'B' || os_prob.osinstance->getVariableTypes()[i] ==
'I') {
139 if ( os_prob.osinstance->getVariableTypes()[i] ==
'B' ) {
144 os_prob.osinstance->getVariableLowerBounds()[ i],
145 os_prob.osinstance->getVariableUpperBounds()[ i]) );
150 os_prob.osinstance->getVariableLowerBounds()[ i],
151 os_prob.osinstance->getVariableUpperBounds()[ i] ));
156 const int num_cons = os_prob.osinstance->getConstraintNumber();
160 for (i=0; i < num_cons; ++i) {
162 os_prob.osinstance->getConstraintUpperBounds()[ i]));
166 bool columnMajor = os_prob.osinstance->getLinearConstraintCoefficientMajor();
168 CoinPackedMatrix* core_matrix =
new CoinPackedMatrix(
170 columnMajor? os_prob.osinstance->getConstraintNumber() : os_prob.osinstance->getVariableNumber(),
171 columnMajor? os_prob.osinstance->getVariableNumber() : os_prob.osinstance->getConstraintNumber(),
172 os_prob.osinstance->getLinearConstraintCoefficientNumber(),
173 columnMajor? os_prob.osinstance->getLinearConstraintCoefficientsInColumnMajor()->values :
174 os_prob.osinstance->getLinearConstraintCoefficientsInRowMajor()->values,
175 columnMajor? os_prob.osinstance->getLinearConstraintCoefficientsInColumnMajor()->indexes :
176 os_prob.osinstance->getLinearConstraintCoefficientsInRowMajor()->indexes,
177 columnMajor? os_prob.osinstance->getLinearConstraintCoefficientsInColumnMajor()->starts :
178 os_prob.osinstance->getLinearConstraintCoefficientsInRowMajor()->starts,
182 matrix->
copyOf(*core_matrix, os_prob.osinstance->getDenseObjectiveCoefficients()[0], os_prob.osinstance->getVariableLowerBounds(),
183 os_prob.osinstance->getVariableUpperBounds(), os_prob.osinstance->getConstraintLowerBounds(),
184 os_prob.osinstance->getConstraintUpperBounds());
205 std::cout <<
"Default BCP display of the feasible solution: ***************" << std::endl << std::endl;
222 std::cout <<
"Inside OS_tm destructor" << std::endl;
223 delete os_prob.osilreader;
virtual ~OS_tm()
Default destructor.
virtual void display_feasible_solution(const BCP_solution *sol)
Display a feasible solution.
BCP_buffer & pack(const T &value)
Pack a single object of type T.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
int main(int argc, char *argv[])
BCP_process_t
This enumerative constant describes the various process types.
Core cuts are the cuts that always stay in the LP formulation.
void readInput(const char *filename)
Read input and set up data in class OS_prob.
Core variables are the variables that always stay in the LP formulation.
void push_back(const_reference x)
Append x to the end of the vector.
void copyOf(const CoinPackedMatrix &m, const double *OBJ, const double *CLB, const double *CUB, const double *RLB, const double *RUB)
Set up the LP relaxation by making a copy of the arguments.
int bcp_main(int argc, char *argv[], USER_initialize *user_init)
This is the function the user must invoke when (s)he is ready to turn contrl over to BCP...
Used to read an OSiL string.
virtual void pack_module_data(BCP_buffer &buf, BCP_process_t ptype)
Pack data into a buffer; will not work in parallel environment as it uses pointer.
virtual void create_root(BCP_vec< BCP_var * > &added_vars, BCP_vec< BCP_cut * > &added_cuts, BCP_user_data *&user_data)
Create the root node of the enumeration.
Class taking care of interaction between user data and Bcp.
OS_tm()
Default constructor.
virtual void display_feasible_solution(const BCP_solution *sol)
Print a feasible solution.
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
This class describes the message buffer used for all processes of BCP.
virtual void initialize_core(BCP_vec< BCP_var_core * > &vars, BCP_vec< BCP_cut_core * > &cuts, BCP_lp_relax *&matrix)
Packing of algorithmic cuts.
class used to make it easy to read and write files.
used for throwing exceptions.
General integer variable.
An object of type BCP_lp_relax holds the description of an lp relaxation.
This is the abstract base class for a solution to a Mixed Integer Programming problem.