33 #include "CoinMpsIO.hpp"
34 #include "CoinLpIO.hpp"
35 #include "CoinPackedMatrix.hpp"
37 #include "CglCutGenerator.hpp"
39 #include "OsiCuts.hpp"
40 #include "OsiSolverInterface.hpp"
42 #include "AlpsEnumProcessT.h"
43 #include "AlpsParams.h"
44 #include "AlpsTreeNode.h"
46 #include "BcpsBranchStrategy.h"
47 #include "BcpsObject.h"
48 #include "BcpsObjectPool.h"
49 #include "BcpsModel.h"
408 virtual void importModel(std::vector<BlisVariable *> vars,
409 std::vector<BlisConstraint *> cons);
412 virtual void readParameters(
const int argnum,
const char *
const *arglist);
440 virtual void setSolver(OsiSolverInterface *si) { origLpSolver_ = si; }
543 std::cout <<
"3. cutoff_ = "<< cutoff_
544 <<
"; inc = " << inc << std::endl;
549 lpSolver_->setDblParam(OsiDualObjectiveLimit, co);
561 int & numObjectInfs);
593 branchStrategy_ = method;
599 branchStrategy_ = &method;
618 inline BcpsObject *
objects(
int which) {
return objects_[which]; }
626 sharedObjectMark_[k] = 0;
652 double integerTolerance = 1.0e-5;
653 double nearest = floor(value + 0.5);
654 if (fabs(value - nearest) <= integerTolerance) {
686 const char * name = NULL,
688 int cutGenerationFrequency = 1,
690 bool atSolution =
false,
691 bool whenInfeasible =
false);
737 oldConstraints_ = NULL;
783 bool ifNotSimpleIntegers,
784 int defaultValue = 1000);
791 if (priority_)
return priority_[sequence];
821 numIterations_ += newIter;
822 aveIterations_ = numIterations_ /
numNodes_;
838 virtual void nodeLog(AlpsTreeNode *node,
bool force);
850 AlpsReturnStatus
encodeBlis(AlpsEncoded *encoded)
const;
853 AlpsReturnStatus
decodeBlis(AlpsEncoded &encoded);
879 using AlpsKnowledge::encode ;
881 virtual AlpsEncoded*
encode()
const;
virtual OsiSolverInterface * getSolver()
Get lp solver.
BcpsBranchStrategy * branchStrategy_
Variable selection function.
This class contains the solutions generated by the LP solver (either primal or dual.
int oldConstraintsSize_
The memory size allocated for oldConstraints_.
BlisModel()
Default construtor.
const double * getColUpper()
Get column upper bound.
int getNumSolutions() const
Get number of solutions.
void setCutStrategy(BlisCutStrategy u)
Set constraint generation strategy.
int getAveIterations() const
Get the average iterations it took to solve a lp.
bool isRoot_
If root node.
int getDenseConCutoff() const
Get the thresheld to be considered as a dense constraint.
double * conLB()
Get original constraint bounds arrary.
BlisSolution * feasibleSolutionHeur(const double *solution)
Test if a solution found by heuristic is feasible.
double getNodeWeight() const
BcpsBranchStrategy * branchStrategy() const
Get the current branching strategy.
virtual void postprocess()
Postprocessing the searching results.
int numOldConstraints_
Number of old constraints.
BcpsObject ** objects()
Get the array of objects.
CoinMessageHandler * blisMessageHandler() const
Get the message handler.
BcpsObject ** objects_
The set of objects.
BcpsBranchStrategy * rampUpBranchStrategy_
double integerTol_
Integer tolerance.
int numCols_
Number of columns/rows/elements.
void setSharedObjectMark(int i)
Mark object to be shared.
BcpsConstraintPool * constraintPool_
Store all the cuts.
double getCutoff() const
Get cut off value.
virtual bool fathomAllNodes()
Return true, if all nodes can be fathomed.
int * priority_
Priorities of integer object.
void createIntgerObjects(bool startAgain)
Identify integer variable.
double incObjValue_
Incumbent objective value.
OsiSolverInterface * presolvedLpSolver_
Presolved.
void setNumBranchResolve(int num)
Set the maximum number of resolve during branching.
int maxNumCons_
Number of cuts can be generators.
BlisHeuristic * heuristics(int i) const
Get a specific heuristic.
void setNumOldConstraints(int num)
Set number of old constraints.
int numNodes_
Number of processed nodes.
BcpsConstraintPool * constraintPoolReceive()
Access receive constraint pool.
int getNumHeurSolutions() const
Get number of heuristic solutions.
void setDenseConCutoff(int cutoff)
Set the thresheld to be considered as a dense constraint.
void setNodeWeight(double nw)
int numIterations_
Number of lp(Simplex) iterations.
BlisHeuristic ** heuristics_
The list of heuristics.
int getNumIterations() const
Get how many iterations it took to solve the problem.
int getNumBranchResolve()
Get the maximum number of resolve during branching.
int aveIterations_
Average number of lp iterations to solve a subproblem.
BlisConGenerator ** generators_
The list of cut generators used.
BlisHotStartStrategy hotstartStrategy_
void setOldConstraints(BlisConstraint **old)
set old constraints.
void setConLb(double *cl)
Pass column upper bounds.
void addHeuristic(BlisHeuristic *heur)
Add a heuristic.
void setBranchingMethod(BcpsBranchStrategy *method)
Set the branching strategy.
int numObjects_
Number of objects.
int numHeuristics() const
Get the number of heuristics.
double * startVarLB()
The starting variable bounds arrary of a subproblem (internal use).
int getOldConstraintsSize() const
Get max number of old constraints.
virtual void nodeLog(AlpsTreeNode *node, bool force)
Node log.
int heurCallFrequency_
Frequency of using heuristics.
int getMaxNumCons() const
Get the max number of cuts can be generated.
void setVarLb(double *lb)
Pass variable upper bounds.
BlisParams * BlisPar()
Access parameters.
int storeSolution(BlisSolutionType how, BlisSolution *sol)
Record a new incumbent solution and update objectiveValue.
BlisHeurStrategy heurStrategy_
If use heuristics.
void delOldConstraints()
Set max number of old constraints.
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack Blis portion of the model into an encoded object.
A interface to Osi/Coin Presolve.
void setNumObjects(int num)
Set the number of objects.
int getNumCols()
Get number of columns.
void addCutGenerator(BlisConGenerator *generator)
Add a Blis cut generator.
virtual OsiSolverInterface * solver()
Get lp solver.
BlisParams * BlisPar_
Blis parameters.
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack Blis portion of the model from an encoded object.
double cutoff_
Cutoff in lp solver.
const double * getColLower()
Get column lower bound.
BcpsBranchStrategy * rampUpBranchStrategy() const
void deleteObjects()
Delete all object information.
void setSolEstimate(double est)
Set the solution estimate of the active node.
void setColType(char *colType)
Pass variable types.
bool entry(const chrParams key) const
void unpackSharedVariables(AlpsEncoded &encoded)
Unpack and store shared variables.
double * varLB()
Get variable bounds arrary.
BlisCutStrategy cutStrategy_
If use cut generators.
void clearSharedObjectMark()
Clear all the share mark.
BcpsConstraintPool * constraintPoolSend_
Constraints that can be sent/broadcasted to other processes.
int * tempVarLBPos_
Tempory storage for var/con indices.
bool checkInteger(double value) const
Check if a value is integer.
void unpackSharedPseudocost(AlpsEncoded &encoded)
Unpack and store shared pseduocost.
int numCutGenerators_
Number of cut generators used.
virtual void writeParameters(std::ostream &outstream) const
Write out parameters.
virtual void setSolver(OsiSolverInterface *si)
Set lp solver.
void setNumCons(int num)
Pass column upper bounds.
int getNumRows()
Get number of rows.
double * conRandoms_
Random keys.
CoinMessages blisMessages()
Return messages.
OsiCuts newCutPool_
Store new cuts in each pass.
void gutsOfDestructor()
Actual destructor.
double optimalRelGap_
Input relative optimal gap.
virtual BlisSolution * userFeasibleSolution(const double *solution, bool &feasible)
User's criteria for a feasible solution.
void setMaxNumCons(int m)
Set the max number of cuts can be generated.
void createObjects()
Create variables and constraints.
virtual void preprocess()
Preprocessing the model.
void packSharedPseudocost(AlpsEncoded *encoded, int numToShare)
Retrieve and pack shared pseudocost.
double * getObjCoef() const
Get objective coefficients.
void addObjects(int numObjects, BcpsObject **objects)
Add in object information.
The value added to relaxation value when deciding fathom.
int numObjects() const
Get the number of objects.
const int * priority() const
Priorities.
void setNumElems(int num)
Pass column upper bounds.
int * getIntObjIndices() const
Get integers' object indices.
virtual bool setupSelf()
All processes call this function.
virtual void presolveForTheWholeTree()
BcpsObject * objects(int which)
Get the specified object.
int getNumOldConstraints() const
Get number of old constraints.
double * startVarLB_
Starting var/con bounds for processing each node.
BlisConstraint ** oldConstraints()
Access old constraints.
virtual void modelLog()
Log of specific models.
int denseConCutoff_
Dense constraint cutoff.
void setObjCoef(double *obj)
Pass objective coefficients.
std::vector< BcpsVariable * > inputVar_
User's input objects.
BcpsConstraintPool * constraintPool()
Access constraint pool.
int cutGenerationFrequency_
Frequency of cut generation.
virtual AlpsTreeNode * createRoot()
For parallel code, only the master calls this function.
virtual void unpackSharedKnowledge(AlpsEncoded &)
Unpack and store shared knowledge from an encoded object.
void setVarUb(double *ub)
Pass variable lower bounds.
double optimalAbsGap_
Input absolute optimal gap.
CoinMessageHandler * blisMessageHandler_
Message handler.
OsiSolverInterface * origLpSolver_
Input by user.
int numIntObjects_
Column types.
int numBranchResolve_
Maximum number of resolve during branching.
CoinPackedMatrix * colMatrix_
Column majored matrix.
std::vector< AlpsTreeNode * > leafToRootPath
Record the path from leaf to root.
double * incumbent()
Return best ip solution found so far.
virtual void registerKnowledge()
Register knowledge.
BlisConstraint ** oldConstraints_
Temporary store old cuts at a node when installing a node.
virtual void decodeToSelf(AlpsEncoded &)
The method that decodes the model from an encoded object.
void setCutoff(double co)
Set cut off value.
virtual void readInstance(const char *dataFile)
For parallel code, only the master calls this function.
OsiSolverInterface * lpSolver_
Actually used.
double * varLB_
Variable and constraint bounds.
AlpsTreeNode * activeNode_
Active node.
std::vector< BcpsConstraint * > inputCon_
CoinMessages blisMessages_
Blis messages.
double * getConRandoms() const
Get randoms for check parallel constraints.
double objSense_
Objective function.
void addNumStrong(int num=1)
Add num to number of strong branchings.
void setNumVars(int num)
Pass column upper bounds.
virtual void readParameters(const int argnum, const char *const *arglist)
Read in Alps, Blis parameters.
int * getIntColIndices() const
Get integers' column indices.
double * incumbent_
Incumbent.
int getNumIntObjects() const
Get number of integers.
void unpackSharedConstraints(AlpsEncoded &encoded)
Unpack and store shared constraints.
void addNumIterations(int newIter)
Increment Iteration count.
void passInPriorities(const int *priorities, bool ifNotSimpleIntegers, int defaultValue=1000)
Pass in branching priorities.
double getLpObjValue() const
Get current objective function value.
void packSharedVariables(AlpsEncoded *encoded)
Retrieve and pack shared variables.
void addNumNodes(int newNodes=1)
Increment node count.
char * sharedObjectMark_
The objects that can be shared.
void packSharedConstraints(AlpsEncoded *encoded)
Retrieve and pack shared constraints.
double cutoffInc_
Cutoff increment.
void setBranchingMethod(BcpsBranchStrategy &method)
Set the branching stratedy.
BcpsConstraintPool * constraintPoolSend()
Access send constraint pool.
void setCutStrategy(int f)
Set constraint generation frequency.
BcpsConstraintPool * constraintPoolReceive_
Constraints that are received from other processses.
virtual ~BlisModel()
Destructor.
const double * getLpSolution() const
Get active lp solution.
void init()
Intialize member data.
virtual void importModel(std::vector< BlisVariable * > vars, std::vector< BlisConstraint * > cons)
For parallel code, only the master calls this function.
int getCutGenerationFrequency() const
Query constraint generation frequency.
BlisCutStrategy getCutStrategy() const
Query constraint generation strategy.
int numStrong_
Number of strong branching.
virtual AlpsEncoded * packSharedKnowlege()
Pack knowledge to be shared with others into an encoded object.
int boundingPass_
The number of passes during bounding procedure.
double currRelGap_
Current relative optimal gap.
int numCutGenerators() const
Get the number of cut generators.
double * startConLB()
The starting constraint bounds arrary of a subproblem (internal use).
bool resolve()
Resolving a lp.
int * tempVarLBPos()
Temparory storage.
virtual BlisSolution * feasibleSolution(int &numIntegerInfs, int &numObjectInfs)
Test the current LP solution for feasiblility.
void setConUb(double *cu)
Pass column lower bounds.
int getNumStrong()
Get number of strong branchings.
BlisConGenerator * cutGenerators(int i) const
Get a specific cut generator.
int getNumNodes() const
Get how many Nodes it took to solve the problem.
virtual AlpsEncoded * encode() const
The method that encodes the model into an encoded object.
void setActiveNode(AlpsTreeNode *node)
Set active node.
void setOldConstraintsSize(int num)
Set max number of old constraints.
Interface between Blis and Cut Generation Library.
void setColMatrix(CoinPackedMatrix *mat)
Pass a matrix in.
int numHeuristics_
Number of heuristics.
double currAbsGap_
Current absolute optimal gap.
int priority(int sequence) const
Returns priority level for an object (or 1000 if no priorities exist)