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;
BlisHeuristic * heuristics(int i) const
Get a specific heuristic.
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.
double * getConRandoms() const
Get randoms for check parallel constraints.
void setCutStrategy(BlisCutStrategy u)
Set constraint generation strategy.
bool isRoot_
If root node.
double * conLB()
Get original constraint bounds arrary.
BlisSolution * feasibleSolutionHeur(const double *solution)
Test if a solution found by heuristic is feasible.
virtual void postprocess()
Postprocessing the searching results.
int numOldConstraints_
Number of old constraints.
BcpsObject ** objects()
Get the array of objects.
BcpsObject ** objects_
The set of objects.
BcpsBranchStrategy * rampUpBranchStrategy_
double integerTol_
Integer tolerance.
int getAveIterations() const
Get the average iterations it took to solve a lp.
int numCols_
Number of columns/rows/elements.
void setSharedObjectMark(int i)
Mark object to be shared.
BcpsConstraintPool * constraintPool_
Store all the cuts.
virtual bool fathomAllNodes()
Return true, if all nodes can be fathomed.
int * priority_
Priorities of integer object.
BlisCutStrategy getCutStrategy() const
Query constraint generation strategy.
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.
void setNumOldConstraints(int num)
Set number of old constraints.
int numNodes_
Number of processed nodes.
double getLpObjValue() const
Get current objective function value.
BcpsConstraintPool * constraintPoolReceive()
Access receive constraint pool.
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 getNumBranchResolve()
Get the maximum number of resolve during branching.
int priority(int sequence) const
Returns priority level for an object (or 1000 if no priorities exist)
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.
double * startVarLB()
The starting variable bounds arrary of a subproblem (internal use).
virtual void nodeLog(AlpsTreeNode *node, bool force)
Node log.
int heurCallFrequency_
Frequency of using heuristics.
void setVarLb(double *lb)
Pass variable upper bounds.
int getNumIterations() const
Get how many iterations it took to solve the problem.
BlisParams * BlisPar()
Access parameters.
int storeSolution(BlisSolutionType how, BlisSolution *sol)
Record a new incumbent solution and update objectiveValue.
bool entry(const chrParams key) const
BlisHeurStrategy heurStrategy_
If use heuristics.
void delOldConstraints()
Set max number of old constraints.
A interface to Osi/Coin Presolve.
void setNumObjects(int num)
Set the number of objects.
int getNumNodes() const
Get how many Nodes it took to solve the problem.
int getNumCols()
Get number of columns.
void addCutGenerator(BlisConGenerator *generator)
Add a Blis cut generator.
int getNumHeurSolutions() const
Get number of heuristic solutions.
virtual OsiSolverInterface * solver()
Get lp solver.
BlisParams * BlisPar_
Blis parameters.
BcpsBranchStrategy * branchStrategy() const
Get the current branching strategy.
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack Blis portion of the model from an encoded object.
double getCutoff() const
Get cut off value.
int getDenseConCutoff() const
Get the thresheld to be considered as a dense constraint.
double cutoff_
Cutoff in lp solver.
const double * getColLower()
Get column lower bound.
int numHeuristics() const
Get the number of heuristics.
int getNumIntObjects() const
Get number of integers.
const double * getLpSolution() const
Get active lp solution.
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.
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.
void unpackSharedPseudocost(AlpsEncoded &encoded)
Unpack and store shared pseduocost.
int numCutGenerators_
Number of cut generators used.
int getMaxNumCons() const
Get the max number of cuts can be generated.
int * getIntObjIndices() const
Get integers' object indices.
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.
const int * priority() const
Priorities.
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.
BlisConGenerator * cutGenerators(int i) const
Get a specific cut generator.
void setMaxNumCons(int m)
Set the max number of cuts can be generated.
virtual AlpsEncoded * encode() const
The method that encodes the model into an encoded object.
int getCutGenerationFrequency() const
Query constraint generation frequency.
void createObjects()
Create variables and constraints.
virtual void preprocess()
Preprocessing the model.
void packSharedPseudocost(AlpsEncoded *encoded, int numToShare)
Retrieve and pack shared pseudocost.
void addObjects(int numObjects, BcpsObject **objects)
Add in object information.
The value added to relaxation value when deciding fathom.
void setNumElems(int num)
Pass column upper bounds.
virtual bool setupSelf()
All processes call this function.
virtual void presolveForTheWholeTree()
BcpsObject * objects(int which)
Get the specified object.
double * startVarLB_
Starting var/con bounds for processing each node.
BlisConstraint ** oldConstraints()
Access old constraints.
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack Blis portion of the model into an encoded object.
virtual void modelLog()
Log of specific models.
int denseConCutoff_
Dense constraint cutoff.
int numObjects() const
Get the number of objects.
void setObjCoef(double *obj)
Pass objective coefficients.
std::vector< BcpsVariable * > inputVar_
User's input objects.
BcpsConstraintPool * constraintPool()
Access constraint pool.
bool checkInteger(double value) const
Check if a value is integer.
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.
CoinMessageHandler * blisMessageHandler() const
Get the message handler.
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.
int getNumOldConstraints() const
Get number of old constraints.
BcpsBranchStrategy * rampUpBranchStrategy() const
int getOldConstraintsSize() const
Get max number of old constraints.
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.
double getNodeWeight() const
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_
virtual void importModel(std::vector< BlisVariable *> vars, std::vector< BlisConstraint *> cons)
For parallel code, only the master calls this function.
CoinMessages blisMessages_
Blis messages.
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.
double * incumbent_
Incumbent.
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.
void packSharedVariables(AlpsEncoded *encoded)
Retrieve and pack shared variables.
void addNumNodes(int newNodes=1)
Increment node count.
int numCutGenerators() const
Get the number of cut generators.
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.
void init()
Intialize member data.
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.
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.
int * getIntColIndices() const
Get integers' column indices.
virtual void writeParameters(std::ostream &outstream) const
Write out parameters.
void setConUb(double *cu)
Pass column lower bounds.
int getNumStrong()
Get number of strong branchings.
double * getObjCoef() const
Get objective coefficients.
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.
int getNumSolutions() const
Get number of solutions.
double currAbsGap_
Current absolute optimal gap.