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;
341 return stats.nsqterm == stats.nterms + stats.nvars;
345 inline bool checkCoeffCond(
const ConstraintStats& stats,
349 return stats.nposcoefone == stats.nterms + stats.nvars ||
350 (stats.nposcoef == stats.nterms + stats.nvars &&
351 stats.eqwt == stats.nterms + stats.nvars);
353 return stats.nnegcoefone == stats.nterms + stats.nvars ||
354 (stats.nnegcoef == stats.nterms + stats.nvars &&
355 stats.eqwt == stats.nterms + stats.nvars);
393 virtual ConstraintPtr
newConstraint(FunctionPtr f,
double lb,
double ub);
404 virtual ConstraintPtr
newConstraint(FunctionPtr f,
double lb,
double ub,
416 virtual ObjectivePtr
newObjective(FunctionPtr f,
double cb,
432 virtual ObjectivePtr
newObjective(FunctionPtr f,
double cb,
450 virtual SOSPtr
newSOS(
int n,
SOSType type,
const double* weights,
451 const VarVector& vars,
int priority,
467 virtual SOSPtr
newSOS(
int n,
SOSType type,
const double* weights,
468 const VarVector& vars,
int priority);
510 virtual void newVariables(VariableConstIterator v_begin,
511 VariableConstIterator v_end,
535 virtual NonlinearFunctionPtr removeNonlinFromObj();
543 virtual void resConTypCnt();
576 virtual void setHessian(HessianOfLagPtr hessian);
600 virtual void setInitVal(VariablePtr v,
double val);
601 virtual void setInitValByInd(
UInt ind,
double val);
624 virtual SOSConstIterator sos1Begin()
const
626 return sos1_.begin();
628 virtual SOSConstIterator sos1End()
const
632 virtual SOSConstIterator sos2Begin()
const
634 return sos2_.begin();
636 virtual SOSConstIterator sos2End()
const
650 virtual void subst(VariablePtr out, VariablePtr in,
double rat = 1.0);
658 return vars_.begin();
668 virtual void write(std::ostream& out, std::streamsize out_p = 6)
const;
671 virtual void writeSize(std::ostream& out)
const;
674 void statistics(std::ostream& out)
const;
676 const double INFTY = std::numeric_limits<double>::infinity();
704 void printConstraintStatistics_();
707 void printConstraintStatisticsQuad_();
745 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: Function.h:37
Definition: HessianOfLag.h:47
Definition: Jacobian.h:53
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:2424
virtual void changeConstraint(ConstraintPtr con, LinearFunctionPtr lf, double lb, double ub)
Change the linear function, and the bounds of a constraint.
Definition: Problem.cpp:273
ConstProblemSizePtr getSize() const
Fill up the statistics about the size of the problem into size_.
Definition: Problem.cpp:1868
virtual void prepareForSolve()
Setup problem data-structures for solving it.
Definition: Problem.cpp:2278
UInt nextCId_
ID of the next constraint.
Definition: Problem.h:751
virtual void addToObj(LinearFunctionPtr lf)
Add a linear function to the objective.
Definition: Problem.cpp:97
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:151
virtual ConstraintPtr getConstraint(UInt index) const
Return a pointer to the constraint with a given index.
Definition: Problem.cpp:1801
virtual void unsetEngine()
Should be called in the Engine's destructor.
Definition: Problem.cpp:2509
virtual bool isLinear()
Returns true if the problem has only linear constraints and linear objectives.
Definition: Problem.cpp:1958
VarVector vars_
Vector of variables.
Definition: Problem.h:778
virtual void resetDer()
Definition: Problem.cpp:2324
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:2302
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:2054
virtual void removeObjective()
Remove objective from the Problem.
Definition: Problem.cpp:2291
ProblemPtr clone(EnvPtr env) const
Clone the given Problem class. Jacobian and Hessian in the cloned problem are NULL.
Definition: Problem.cpp:1034
virtual void countVarTypes_()
Fill up the size_ with number of variables of each type.
Definition: Problem.cpp:1587
SOSVector sos2_
SOS2 constraints.
Definition: Problem.h:775
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:2229
virtual void countObjTypes_()
Count the types of objectives and fill the values in size_.
Definition: Problem.cpp:1562
Problem(EnvPtr env)
Default constructor.
Definition: Problem.cpp:25
virtual void countConsTypes_()
Count the types of constraints and fill the values in size_.
Definition: Problem.cpp:1493
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:2094
virtual void writeSize(std::ostream &out) const
Write the problem size to logger_.
Definition: Problem.cpp:2569
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:1847
virtual DoubleVector * getDebugSol() const
Give a pointer to the debug solution.
Definition: Problem.cpp:1806
void setNativeDer()
Ask Problem to construct its own jacobian and hessian using Minotaur's native code for nonlinear func...
Definition: Problem.cpp:2429
DoubleVector * debugSol_
A solution to be used for debugging against accidentally cutting of feasible points.
Definition: Problem.h:730
HessianOfLagPtr hessian_
Pointer to the hessian of the lagrangean. Could be NULL.
Definition: Problem.h:736
virtual void setEngine(Engine *engine)
Set the engine that is used to solve this problem.
Definition: Problem.cpp:2369
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:182
virtual void setVarType(VariablePtr var, VariableType type)
Change the variable type.
Definition: Problem.cpp:2445
UInt numDVars_
Number of variables marked for deletion.
Definition: Problem.h:763
ConstraintVector cons_
Vector of constraints.
Definition: Problem.h:713
Engine * engine_
Engine that must be updated if problem is loaded to it, could be null.
Definition: Problem.h:733
bool consModed_
Flag that is turned on if the constraints are added or modified.
Definition: Problem.h:724
double getSizeEstimate()
Calculate and return a measure of the size of the problem.
Definition: Problem.cpp:2545
virtual void delMarkedVars(bool keep=false)
Definition: Problem.cpp:1664
virtual void reverseSense(ConstraintPtr cons)
Reverse the sense of a constraint.
Definition: Problem.cpp:2355
virtual void negateObj()
The objective is multiplied by -1.
Definition: Problem.cpp:2041
virtual void addToCons(ConstraintPtr cons, double c)
Add 'c' to both lb and ub of a constraint.
Definition: Problem.cpp:121
virtual JacobianPtr getJacobian() const
Return the jacobian. Could be NULL.
Definition: Problem.cpp:1816
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:2482
virtual int checkConVars() const
Check whether variables used in the constraints belong to the problem or not.
Definition: Problem.cpp:319
virtual ~Problem()
Destroy.
Definition: Problem.cpp:47
virtual VariablePtr newVariable(VarSrcType stype=VarOrig)
Add a new continuous, unbounded variable to the Problem.
Definition: Problem.cpp:2189
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:2361
virtual VariablePtr getVariable(UInt index) const
Return a pointer to the variable with a given index.
Definition: Problem.cpp:1873
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:1883
virtual bool isQP()
Returns true if the problem has (1) linear or quadratic objective, and (2) linear constraints only.
Definition: Problem.cpp:1998
UInt getNumSOS1()
Return the number of SOS Type 1 constraints.
Definition: Problem.cpp:1842
virtual void changeObj(FunctionPtr f, double cb)
Replace the objective function with a new function.
Definition: Problem.cpp:305
virtual void calculateSize(bool shouldRedo=false)
Fill up the statistics about the size of the problem into size_.
Definition: Problem.cpp:126
virtual UInt getNumJacNnzs() const
Return the number of non zerors in the jacobian of the constraints.
Definition: Problem.cpp:1829
virtual void findVarFunTypes_()
Update the function types of all variables based on whether they appear as linear,...
Definition: Problem.cpp:1723
ProblemPtr shuffle(bool varshuff, bool conshuff, EnvPtr env)
shuffle variables and constraints while making a clone of the problem
Definition: Problem.cpp:1144
LoggerPtr logger_
Pointer to the log manager. All output messages are sent to it.
Definition: Problem.h:742
virtual void setHessian(HessianOfLagPtr hessian)
Add a pointer to the hessian of the Lagrangean.
Definition: Problem.cpp:2377
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:2159
VarVector varsRem_
Vector of variables removed from the problem but not yet freed from memory.
Definition: Problem.h:784
UInt numDCons_
Number of constraints marked for deletion.
Definition: Problem.h:760
virtual void setInitialPoint(const double *x)
Set an initial point.
Definition: Problem.cpp:2387
virtual HessianOfLagPtr getHessian() const
Return the hessian of the lagrangean. Could be NULL.
Definition: Problem.cpp:1811
virtual void markDelete(ConstraintPtr con)
Mark a constraint for deleting.
Definition: Problem.cpp:2027
UInt nextVId_
ID of the next variable.
Definition: Problem.h:757
ObjectivePtr obj_
Objective, could be NULL.
Definition: Problem.h:766
ProblemSizePtr size_
Size statistics for this Problem.
Definition: Problem.h:769
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:1821
bool varsModed_
True if variables delete, added or their bounds changed.
Definition: Problem.h:787
virtual VariableConstIterator varsEnd() const
Iterate over variables.
Definition: Problem.h:662
virtual ProblemType findType()
Return what type of problem it is. May result in re-calculation of the problem size.
Definition: Problem.cpp:1701
SOSVector sos1_
SOS1 constraints.
Definition: Problem.h:772
virtual void delMarkedCons()
Delete marked constraints.
Definition: Problem.cpp:1620
double getObjValue(const double *x, int *err) const
Return the value of objective function at given point x.
Definition: Problem.cpp:1859
virtual VariableConstIterator varsBegin() const
Iterate over variables.
Definition: Problem.h:656
virtual bool hasNativeDer() const
Return true if the derivative is available through Minotaur's own routines for storing nonlinear func...
Definition: Problem.cpp:1878
int nextSId_
ID of the next SOS constraint.
Definition: Problem.h:754
virtual void objToCons()
Definition: Problem.cpp:2242
bool nativeDer_
If true, set up our own Hessian and Jacobian.
Definition: Problem.h:748
virtual ObjectivePtr newObjective(FunctionPtr f, double cb, ObjectiveType otyp)
Add a new objective. A name is automatically generated by default.
Definition: Problem.cpp:2115
void cg2qf()
Convert all quadratic forms that are stored as CGraph into QuadraticFunction. The order of constraint...
Definition: Problem.cpp:1359
virtual bool isMarkedDel(ConstConstraintPtr con)
Return true if a constraint is marked deleted.
Definition: Problem.cpp:1969
virtual ObjectivePtr getObjective() const
Return a pointer to the objective Function.
Definition: Problem.cpp:1852
virtual bool isQuadratic()
Returns true if the problem has only linear or quadratic constraints and linear or quadratic objectiv...
Definition: Problem.cpp:2012
JacobianPtr jacobian_
Pointer to the jacobian of constraints. Can be NULL.
Definition: Problem.h:739
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:1837
static const std::string me_
For logging.
Definition: Problem.h:745
virtual void write(std::ostream &out, std::streamsize out_p=6) const
only for debugging, developing etc.
Definition: Problem.cpp:2514
Definition: Variable.h:31
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