15#ifndef MINOTAURCGRAPH_H
16#define MINOTAURCGRAPH_H
28 typedef CGraph *CGraphPtr;
29 typedef std::deque<CNode *> CNodeQ;
30 typedef std::vector<CNode *> CNodeVector;
31 typedef std::map<ConstVariablePtr, CNode *, CompareVariablePtr> VarNodeMap;
41 void addConst(
const double eps,
int &err);
58 double eval(
const double *x,
int *err);
61 void evalGradient(
const double *x,
double *grad_f,
int *error);
65 double *values,
int *error);
74 void fillJac(
const double *x,
double *values,
int *error);
88 CNode *getPerspZNode() {
return zNode_; };
103 void resetNodeIndex();
111 void getVars(VariableSet *vars);
179 void prepJac(VarSetConstIter vbeg, VarSetConstIter vend);
199 void varBoundMods(
double lb,
double ub, VarBoundModVector &mods,
203 CNodeQ dNodes() {
return dq_; };
206 void write(std::ostream &out)
const;
238 void fwdGrad_(
CNode *node);
239 void fwdGrad2_(std::stack<CNode *> *st2,
CNode *node);
242 void fillHessInds2_(
CNode *node,
UIntQ *inds);
246 bool isSOSRec_(
CNode *node)
const;
248 void revHess_(
int *error);
249 void revHess2_(std::stack<CNode *> *st2,
double mult,
UInt vind,
250 double *values,
UInt *nz,
int *error);
258 void grad_(
int *error);
261 std::set<ConstVariablePair, CompareVariablePair> &vps);
Declare abstract base class NonlinearFunction.
Declare the OpCodes used in Minotaur.
Declare important 'types' used in Minotaur.
bool isSumOfSquares() const
Check if the function is a sum of square terms.
Definition: CGraph.cpp:1164
double getFixVarOffset(VariablePtr v, double val)
If a variable is fixed at a given value and removed, what is the constant (offset) needed to be added...
Definition: CGraph.cpp:724
void computeBounds(double *lb, double *ub, int *error)
Calculate upper and lower bounds on the function using bounds of the variables.
Definition: CGraph.cpp:172
void sqrRoot(int &err)
Change the nonlinear function to its square-root.
Definition: CGraph.cpp:1407
void fillJac(const double *x, double *values, int *error)
Evaluate and add gradient at a given point to the jacobian.
Definition: CGraph.cpp:496
NonlinearFunctionPtr cloneWithVars(VariableConstIterator, int *) const
Make a clone using new variables.
Definition: CGraph.cpp:126
void finalize()
Definition: CGraph.cpp:558
const CNode * getOut() const
Get the output node.
Definition: CGraph.cpp:1067
void write(std::ostream &out) const
Display the nonlinear function.
Definition: CGraph.cpp:1666
void varBoundMods(double lb, double ub, VarBoundModVector &mods, SolveStatus *status)
Tighten variables based on function bounds.
Definition: CGraph.cpp:1624
FunctionType getType() const
Return the type of function: polynomial, ...
Definition: CGraph.cpp:1079
void addConst(const double eps, int &err)
Add a constant to the function.
Definition: CGraph.cpp:59
void subst(VariablePtr out, VariablePtr in, double rat)
Substitute a variable with another.
Definition: CGraph.cpp:1421
void removeVar(VariablePtr v, double val)
Remove a variable v from the function after fixing it to value val.
Definition: CGraph.cpp:1303
void fillHessStor(LTHessStor *stor)
Fill sparsity of hessian into hessian storage.
Definition: CGraph.cpp:411
void setOut(CNode *node)
Set the node that should be the output of this graph. This node should already be a part of this grap...
Definition: CGraph.cpp:1578
void evalHessian(double mult, const double *x, const LTHessStor *stor, double *values, int *error)
Evaluate and add hessian at a given point.
Definition: CGraph.cpp:218
void multiply(double c)
Multiply by a constant.
Definition: CGraph.cpp:1193
std::string getNlString(int *err)
Return a string in AMPL's .nl format (postfix notation) of this nonlinear function.
Definition: CGraph.cpp:736
double eval(const double *x, int *err)
Evaluate the function at a given point x.
Definition: CGraph.cpp:186
void getVars(VariableSet *vars)
Get variables used in this function.
Definition: CGraph.cpp:1120
void finalHessStor(const LTHessStor *stor)
Finalize hessian preparation.
Definition: CGraph.cpp:517
void evalGradient(const double *x, double *grad_f, int *error)
Evaluate and add gradient at a given point.
Definition: CGraph.cpp:202
NonlinearFunctionPtr getPersp(VariablePtr z, double eps, int *err) const
Take perspective of this function with respect to a given variable.
Definition: CGraph.cpp:986
CGraph()
Default constructor.
Definition: CGraph.cpp:31
void prepJac(VarSetConstIter vbeg, VarSetConstIter vend)
Prepare for evaluating sparse jacobian.
Definition: CGraph.cpp:1285
CNode * newNode(OpCode op, CNode *lchild, CNode *rchild)
Create a new node with one or two children, and add it to the graph. The children should already be a...
Definition: CGraph.cpp:1228
~CGraph()
Default constructor.
Definition: CGraph.cpp:47
CNode denotes a node in the computational graph. It stores the op-code, children, parents and other a...
Definition: CNode.h:48
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: QuadraticFunction.h:38
Definition: Variable.h:31
Definition: ActiveNodeStore.h:20
std::map< ConstVariablePtr, double, CompareVariablePtr > VariableGroup
Variables should always be constant within a group.
Definition: Types.h:511
std::deque< UInt > UIntQ
Containers for standard types.
Definition: Types.h:33
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
FunctionType
Different types of functions in Minotaur.
Definition: Types.h:65
SolveStatus
Different states an algorithm like branch-and-bound can be in.
Definition: Types.h:158
Definition: HessianOfLag.h:21