13#ifndef MINOTAURPROBLEM_H
14#define MINOTAURPROBLEM_H
69 double sumnegwt = 0.0;
121 double lb,
double ub);
149 virtual void classifyCon();
182 return cons_.begin();
186 virtual ConstraintConstIterator
consEnd()
const
280 double getObjValue(
const double* x,
int* err)
const;
308 virtual bool isFeasible(
const double* x,
double objval,
double& inf_meas)
const;
350 return stats.nsqterm == stats.nterms + stats.nvars;
354 inline bool checkCoeffCond(
const ConstraintStats& stats,
358 return stats.nposcoefone == stats.nterms + stats.nvars ||
359 (stats.nposcoef == stats.nterms + stats.nvars &&
360 stats.eqwt == stats.nterms + stats.nvars);
362 return stats.nnegcoefone == stats.nterms + stats.nvars ||
363 (stats.nnegcoef == stats.nterms + stats.nvars &&
364 stats.eqwt == stats.nterms + stats.nvars);
402 virtual ConstraintPtr
newConstraint(FunctionPtr f,
double lb,
double ub);
413 virtual ConstraintPtr
newConstraint(FunctionPtr f,
double lb,
double ub,
425 virtual ObjectivePtr
newObjective(FunctionPtr f,
double cb,
441 virtual ObjectivePtr
newObjective(FunctionPtr f,
double cb,
459 virtual SOSPtr
newSOS(
int n,
SOSType type,
const double* weights,
460 const VarVector& vars,
int priority,
476 virtual SOSPtr
newSOS(
int n,
SOSType type,
const double* weights,
477 const VarVector& vars,
int priority);
519 virtual void newVariables(VariableConstIterator v_begin,
520 VariableConstIterator v_end,
544 virtual NonlinearFunctionPtr removeNonlinFromObj();
552 virtual void resConTypCnt();
585 virtual void setHessian(HessianOfLagPtr hessian);
609 virtual void setInitVal(VariablePtr v,
double val);
610 virtual void setInitValByInd(
UInt ind,
double val);
633 virtual SOSConstIterator sos1Begin()
const
635 return sos1_.begin();
637 virtual SOSConstIterator sos1End()
const
641 virtual SOSConstIterator sos2Begin()
const
643 return sos2_.begin();
645 virtual SOSConstIterator sos2End()
const
659 virtual void subst(VariablePtr out, VariablePtr in,
double rat = 1.0);
667 return vars_.begin();
677 virtual void write(std::ostream& out, std::streamsize out_p = 6)
const;
680 virtual void writeSize(std::ostream& out)
const;
683 void statistics(std::ostream& out)
const;
685 const double INFTY = std::numeric_limits<double>::infinity();
713 void printConstraintStatistics_();
716 void printConstraintStatisticsQuad_();
754 static const std::string
me_;
Get information about a constraint in a given Problem.
Define the base class Engine.
Declare class HessianOfLag to get information about hessian of Lagrangean of a Problem.
Get information about Jacobian of a given Problem.
Declare the Objective class for storing and manipulating objective function.
Declare structure ProblemSize for storing statistics about the problem.
Declare data structures for an SOS-I and SOS-II constraint.
Declare important 'types' used in Minotaur.
Define the Variable class.
The Constraint class is used to manage a constraint.
Definition Constraint.h:61
Definition Environment.h:28
Definition HessianOfLag.h:47
The base class linear function is of the form c'x.
Definition LinearFunction.h:31
Base class for nonlinear functions.
Definition NonlinearFunction.h:31
Definition Objective.h:39
virtual void setJacobian(JacobianPtr jacobian)
Set the jacobian of the constraints.
Definition Problem.cpp:2546
virtual void changeConstraint(ConstraintPtr con, LinearFunctionPtr lf, double lb, double ub)
Change the linear function, and the bounds of a constraint.
Definition Problem.cpp:274
ConstProblemSizePtr getSize() const
Fill up the statistics about the size of the problem into size_.
Definition Problem.cpp:1869
virtual void prepareForSolve()
Setup problem data-structures for solving it.
Definition Problem.cpp:2400
UInt nextCId_
ID of the next constraint.
Definition Problem.h:760
virtual void addToObj(LinearFunctionPtr lf)
Add a linear function to the objective.
Definition Problem.cpp:98
virtual void changeBoundByInd(UInt ind, BoundType lu, double new_val)
Change a bound (lower or upper) on a variable with ID=id.
Definition Problem.cpp:152
virtual ConstraintPtr getConstraint(UInt index) const
Return a pointer to the constraint with a given index.
Definition Problem.cpp:1802
virtual void unsetEngine()
Should be called in the Engine's destructor.
Definition Problem.cpp:2631
virtual bool isLinear()
Returns true if the problem has only linear constraints and linear objectives.
Definition Problem.cpp:2080
VarVector vars_
Vector of variables.
Definition Problem.h:787
virtual void resetDer()
Definition Problem.cpp:2446
virtual ConstraintConstIterator consBegin() const
Iterate over constraints. Returns the 'begin' iterator.
Definition Problem.h:180
virtual QuadraticFunctionPtr removeQuadFromObj()
Remove the quadratic part of objective and return it.
Definition Problem.cpp:2424
virtual UInt getNumVars() const
Return the number of variables.
Definition Problem.h:271
virtual VariablePtr newBinaryVariable()
Add a new binary variable and return a pointer to it. A name is automatically generated by default.
Definition Problem.cpp:2176
virtual void removeObjective()
Remove objective from the Problem.
Definition Problem.cpp:2413
ProblemPtr clone(EnvPtr env) const
Clone the given Problem class. Jacobian and Hessian in the cloned problem are NULL.
Definition Problem.cpp:1035
virtual void countVarTypes_()
Fill up the size_ with number of variables of each type.
Definition Problem.cpp:1588
SOSVector sos2_
SOS2 constraints.
Definition Problem.h:784
virtual void newVariables(VariableConstIterator v_begin, VariableConstIterator v_end, VarSrcType stype=VarOrig)
Clone the variables pointed by the iterators and add them.
Definition Problem.cpp:2351
virtual void countObjTypes_()
Count the types of objectives and fill the values in size_.
Definition Problem.cpp:1563
virtual void countConsTypes_()
Count the types of constraints and fill the values in size_.
Definition Problem.cpp:1494
virtual ConstraintPtr newConstraint(FunctionPtr f, double lb, double ub)
Add a new constraint and return a pointer to it. A name is automatically generated by default.
Definition Problem.cpp:2216
virtual void writeSize(std::ostream &out) const
Write the problem size to logger_.
Definition Problem.cpp:2691
virtual UInt getNumDCons() const
Return the number of constraints marked for deletion.
Definition Problem.h:233
UInt getNumSOS2()
Return the number of SOS Type 2 constraints.
Definition Problem.cpp:1848
virtual DoubleVector * getDebugSol() const
Give a pointer to the debug solution.
Definition Problem.cpp:1807
void setNativeDer()
Ask Problem to construct its own jacobian and hessian using Minotaur's native code for nonlinear func...
Definition Problem.cpp:2551
virtual bool isFeasible(const double *x, double objval, double &inf_meas) const
Check feasibility of original constraints and objective. Evaluates all constraints and the objective ...
Definition Problem.cpp:1960
DoubleVector * debugSol_
A solution to be used for debugging against accidentally cutting of feasible points.
Definition Problem.h:739
HessianOfLagPtr hessian_
Pointer to the hessian of the lagrangean. Could be NULL.
Definition Problem.h:745
virtual void setEngine(Engine *engine)
Set the engine that is used to solve this problem.
Definition Problem.cpp:2491
virtual UInt getNumDVars() const
Return the number of variables marked for deletion.
Definition Problem.h:239
virtual void changeBound(VariablePtr var, BoundType lu, double new_val)
Change a bound (lower or upper) on a variable 'var'.
Definition Problem.cpp:183
virtual void setVarType(VariablePtr var, VariableType type)
Change the variable type.
Definition Problem.cpp:2567
UInt numDVars_
Number of variables marked for deletion.
Definition Problem.h:772
ConstraintVector cons_
Vector of constraints.
Definition Problem.h:722
Engine * engine_
Engine that must be updated if problem is loaded to it, could be null.
Definition Problem.h:742
bool consModed_
Flag that is turned on if the constraints are added or modified.
Definition Problem.h:733
double getSizeEstimate()
Calculate and return a measure of the size of the problem.
Definition Problem.cpp:2667
virtual void delMarkedVars(bool keep=false)
Definition Problem.cpp:1665
virtual void reverseSense(ConstraintPtr cons)
Reverse the sense of a constraint.
Definition Problem.cpp:2477
virtual void negateObj()
The objective is multiplied by -1.
Definition Problem.cpp:2163
virtual void addToCons(ConstraintPtr cons, double c)
Add 'c' to both lb and ub of a constraint.
Definition Problem.cpp:122
virtual JacobianPtr getJacobian() const
Return the jacobian. Could be NULL.
Definition Problem.cpp:1817
virtual void subst(VariablePtr out, VariablePtr in, double rat=1.0)
Substitute a variable 'out' with the variable 'in' through out the problem.
Definition Problem.cpp:2604
virtual int checkConVars() const
Check whether variables used in the constraints belong to the problem or not.
Definition Problem.cpp:320
virtual ~Problem()
Destroy.
Definition Problem.cpp:48
virtual VariablePtr newVariable(VarSrcType stype=VarOrig)
Add a new continuous, unbounded variable to the Problem.
Definition Problem.cpp:2311
virtual void setDebugSol(const DoubleVector &x)
Set a solution that can be checked for accidental cutting off by cuts, branching, reformulations etc.
Definition Problem.cpp:2483
virtual VariablePtr getVariable(UInt index) const
Return a pointer to the variable with a given index.
Definition Problem.cpp:1874
virtual bool isDebugSolFeas(double atol, double rtol)
Returns true if the debug solution is cut off by the constraints of the problem.
Definition Problem.cpp:1884
virtual bool isQP()
Returns true if the problem has (1) linear or quadratic objective, and (2) linear constraints only.
Definition Problem.cpp:2120
UInt getNumSOS1()
Return the number of SOS Type 1 constraints.
Definition Problem.cpp:1843
virtual void changeObj(FunctionPtr f, double cb)
Replace the objective function with a new function.
Definition Problem.cpp:306
virtual void calculateSize(bool shouldRedo=false)
Fill up the statistics about the size of the problem into size_.
Definition Problem.cpp:127
virtual UInt getNumJacNnzs() const
Return the number of non zerors in the jacobian of the constraints.
Definition Problem.cpp:1830
virtual void findVarFunTypes_()
Update the function types of all variables based on whether they appear as linear,...
Definition Problem.cpp:1724
ProblemPtr shuffle(bool varshuff, bool conshuff, EnvPtr env)
shuffle variables and constraints while making a clone of the problem
Definition Problem.cpp:1145
LoggerPtr logger_
Pointer to the log manager. All output messages are sent to it.
Definition Problem.h:751
virtual void setHessian(HessianOfLagPtr hessian)
Add a pointer to the hessian of the Lagrangean.
Definition Problem.cpp:2499
virtual SOSPtr newSOS(int n, SOSType type, const double *weights, const VarVector &vars, int priority, std::string name)
Add a new SOS constraint with a name.
Definition Problem.cpp:2281
VarVector varsRem_
Vector of variables removed from the problem but not yet freed from memory.
Definition Problem.h:793
UInt numDCons_
Number of constraints marked for deletion.
Definition Problem.h:769
virtual void setInitialPoint(const double *x)
Set an initial point.
Definition Problem.cpp:2509
virtual HessianOfLagPtr getHessian() const
Return the hessian of the lagrangean. Could be NULL.
Definition Problem.cpp:1812
virtual void markDelete(ConstraintPtr con)
Mark a constraint for deleting.
Definition Problem.cpp:2149
UInt nextVId_
ID of the next variable.
Definition Problem.h:766
ObjectivePtr obj_
Objective, could be NULL.
Definition Problem.h:775
ProblemSizePtr size_
Size statistics for this Problem.
Definition Problem.h:778
virtual UInt getNumCons() const
Return the number of constraints.
Definition Problem.h:227
virtual UInt getNumHessNnzs() const
Return the number of non-zeros in the hessian of the lagrangean of the problem.
Definition Problem.cpp:1822
bool varsModed_
True if variables delete, added or their bounds changed.
Definition Problem.h:796
virtual VariableConstIterator varsEnd() const
Iterate over variables.
Definition Problem.h:671
virtual ProblemType findType()
Return what type of problem it is. May result in re-calculation of the problem size.
Definition Problem.cpp:1702
SOSVector sos1_
SOS1 constraints.
Definition Problem.h:781
virtual void delMarkedCons()
Delete marked constraints.
Definition Problem.cpp:1621
double getObjValue(const double *x, int *err) const
Return the value of objective function at given point x.
Definition Problem.cpp:1860
virtual VariableConstIterator varsBegin() const
Iterate over variables.
Definition Problem.h:665
virtual bool hasNativeDer() const
Return true if the derivative is available through Minotaur's own routines for storing nonlinear func...
Definition Problem.cpp:1879
int nextSId_
ID of the next SOS constraint.
Definition Problem.h:763
virtual void objToCons()
Definition Problem.cpp:2364
bool nativeDer_
If true, set up our own Hessian and Jacobian.
Definition Problem.h:757
virtual ObjectivePtr newObjective(FunctionPtr f, double cb, ObjectiveType otyp)
Add a new objective. A name is automatically generated by default.
Definition Problem.cpp:2237
void cg2qf()
Convert all quadratic forms that are stored as CGraph into QuadraticFunction. The order of constraint...
Definition Problem.cpp:1360
virtual bool isMarkedDel(ConstConstraintPtr con)
Return true if a constraint is marked deleted.
Definition Problem.cpp:2091
virtual ObjectivePtr getObjective() const
Return a pointer to the objective Function.
Definition Problem.cpp:1853
virtual bool isQuadratic()
Returns true if the problem has only linear or quadratic constraints and linear or quadratic objectiv...
Definition Problem.cpp:2134
JacobianPtr jacobian_
Pointer to the jacobian of constraints. Can be NULL.
Definition Problem.h:748
virtual ConstraintConstIterator consEnd() const
Iterate over constraints. Returns the 'end' iterator.
Definition Problem.h:186
UInt getNumLinCons()
Return the number of linear constraints in the problem.
Definition Problem.cpp:1838
static const std::string me_
For logging.
Definition Problem.h:754
virtual void write(std::ostream &out, std::streamsize out_p=6) const
only for debugging, developing etc.
Definition Problem.cpp:2636
Definition ActiveNodeStore.h:20
BoundType
Different types of variable-bounds.
Definition Types.h:131
ObjectiveType
Definition Types.h:62
VariableType
Different types of variables.
Definition Types.h:76
ProblemType
The different classes of problems.
Definition Types.h:44
SOSType
SOS types.
Definition Types.h:134
VarSrcType
Where did the variable originate from?
Definition Types.h:85
unsigned int UInt
Unsigned integer.
Definition Types.h:30
The Problem that needs to be solved.
Definition Problem.h:51
ProblemSize stores several statistics on the size of the Problem.
Definition ProblemSize.h:23