|
Minotaur 0.4.1
Docs for developers
|
Declare the AMPLNonlinearFunction class for setting up evaluation and derivatives of nonlinear Functions. More...
#include <AMPLNonlinearFunction.h>


Public Member Functions | |
| AMPLNonlinearFunction () | |
| Default constructor. | |
| AMPLNonlinearFunction (Minotaur::UInt i, Minotaur::UInt nvars, ASL *my_asl, bool is_in_obj) | |
| Create a nonlinear function for a given constraint. | |
| Minotaur::NonlinearFunctionPtr | cloneWithVars (Minotaur::VariableConstIterator vbeg, int *err) const |
| Make a clone using new variables. | |
| double | eval (const double *x, int *error) |
| Evaluate the function at a given point x. | |
| void | evalGradient (const double *x, double *grad_f, int *error) |
| Evaluate and add gradient at a given point. | |
| void | evalHessian (const double mult, const double *x, const Minotaur::LTHessStor *stor, double *values, int *error) |
| Evaluate and add hessian at a given point. | |
| void | fillHessStor (Minotaur::LTHessStor *) |
| Fill sparsity of hessian into hessian storage. | |
| void | finalHessStor (const Minotaur::LTHessStor *) |
| Finalize hessian preparation. | |
| void | fillJac (const double *, double *, int *) |
| Evaluate and add gradient at a given point to the jacobian. | |
| void | getVars (Minotaur::VariableSet *) |
| Get variables used in this function. | |
| void | multiply (double c) |
| Multiply by a constant. | |
| void | prepJac (Minotaur::VarSetConstIter, Minotaur::VarSetConstIter) |
| Prepare for evaluating sparse jacobian. | |
| void | setVars (Minotaur::VarSetConstIterator vb, Minotaur::VarSetConstIterator ve) |
| Tell what variables are in this function. | |
| void | write (std::ostream &out) const |
| Display the nonlinear function. | |
Public Member Functions inherited from Minotaur::NonlinearFunction | |
| NonlinearFunction () | |
| Default constructor. | |
| virtual | ~NonlinearFunction () |
| Destroy. | |
| virtual void | addConst (const double d, int &err) |
| Add a constant to the function. | |
| virtual void | sqrRoot (int &err) |
| Change the nonlinear function to its square-root. | |
| virtual void | computeBounds (double *lb, double *ub, int *error) |
| Calculate upper and lower bounds on the function using bounds of the variables. | |
| virtual std::string | getNlString (int *err) |
| Return a string in AMPL's .nl format (postfix notation) of this nonlinear function. | |
| virtual double | getFixVarOffset (VariablePtr, double) |
| If a variable is fixed at a given value and removed, what is the constant (offset) needed to be added. | |
| virtual FunctionType | getType () const |
| Return the type of function: polynomial, ... | |
| virtual bool | hasVar (ConstVariablePtr v) const |
| Check if function contains a variable. | |
| virtual bool | isSumOfSquares () const |
| Check if the function is a sum of square terms. | |
| virtual size_t | numVars () |
| Return the number of variables in this function. | |
| virtual void | removeVar (VariablePtr, double) |
| Remove a variable v from the function after fixing it to value val. | |
| virtual void | subst (VariablePtr, VariablePtr, double) |
| Substitute a variable with another. | |
| virtual NonlinearFunctionPtr | getPersp (VariablePtr z, double eps, int *err) const |
| Take perspective of this function with respect to a given variable. | |
| virtual void | varBoundMods (double, double, VarBoundModVector &, SolveStatus *) |
| Tighten variables based on function bounds. | |
| virtual VariableSet::iterator | varsBegin () |
| First iterator for variables. | |
| virtual VariableSet::iterator | varsEnd () |
| Last iterator for variables. | |
Additional Inherited Members | |
Protected Attributes inherited from Minotaur::NonlinearFunction | |
| VariableSet | vars_ |
| A set of variables used in this function. | |
Declare the AMPLNonlinearFunction class for setting up evaluation and derivatives of nonlinear Functions.
This class does not contain the computational graph of the function. Use it only for evaluating function values and derivatives.
| AMPLNonlinearFunction::AMPLNonlinearFunction | ( | Minotaur::UInt | i, |
| Minotaur::UInt | nvars, | ||
| ASL * | my_asl, | ||
| bool | is_in_obj | ||
| ) |
Create a nonlinear function for a given constraint.
| [in] | i | The constraint number of which we need the nonlinear function. This value is ignored if is_obj is True. |
| [in] | nvars | Total number of variables in the problem. |
| [in] | my_asl | Pointer to ASL for calling its routines. |
| [in] | is_obj | If True, then get function from objective. Otherwise, get function of i-th constriant. |
|
virtual |
Make a clone using new variables.
| [in] | vbeg | it points to the variable id 0. vbeg+k points to variable id k, where k>=0. |
| [out] | err | must be nonzero if function wasn't cloned. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Evaluate the function at a given point x.
| [in] | x | The size of the array x must exceed the highest index of the variables used in the function. |
| [out] | *error | It should be set a positive value if there is error encountered while evaluating. Leave undisturbed otherwise. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Evaluate and add gradient at a given point.
| [in] | x | The size of the array x must exceed the highest index of the variables used in the function. |
| [out] | grad_f | The values of grad_f are incremented with the gradient of this function at x. The array grad_f is dense. |
| [out] | error | It should be set a positive value if there is error encountered while evaluating. Leave undisturbed otherwise. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Evaluate and add hessian at a given point.
| [in] | mult | Multiplier for this objective/constraint function |
| [in] | x | The point where we need the hessian. |
| [in] | stor | The Hessian storage information. |
| [out] | values | The Hessian values to which we add Hessian of this function. |
| [out] | error | We set it to nonzero if any errors are encountered. Do not change it otherwise. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Fill sparsity of hessian into hessian storage.
| [in,out] | stor | We add variables into stor->cols |
Implements Minotaur::NonlinearFunction.
|
virtual |
Evaluate and add gradient at a given point to the jacobian.
| [in] | x | The size of the array x must exceed the highest index of the variables used in the function. |
| [out] | values | The values of jacobian are incremented with the gradient of this function at x. 'values' only contains nonzeros of jacobian. The indices (or offsets) where this nonlinear function should put in the values should be calculated in the prepJac function. |
| [out] | error | It should be set a zero value if there is error encountered while evaluating. Leave undisturbed otherwise. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Finalize hessian preparation.
| [in] | stor | contains the sparsity pattern of hessian of lagrangian. The nonlinear function should save offsets or make other preparation to evaluate hessian. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Get variables used in this function.
| [in] | vars | A set of variable-pointers into which variables are to be inserted. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Multiply by a constant.
| [in] | c | double value with which we want to multiply. |
Implements Minotaur::NonlinearFunction.
|
virtual |
Prepare for evaluating sparse jacobian.
All the variables that are in this function can occur in one or more of linear, quadratic and nonlinear functions. All variables that occur in the whole function can be accessed by iterating between vbeg and vend. This function is used to find the offset for variables that occur in the nonlinear function.
Implements Minotaur::NonlinearFunction.
| void AMPLNonlinearFunction::setVars | ( | Minotaur::VarSetConstIterator | vb, |
| Minotaur::VarSetConstIterator | ve | ||
| ) |
Tell what variables are in this function.
These variabvles are then stored in this class for future use by Minotaur routines.
| [in] | vb | Iterator pointing to first element of set. |
| [in] | ve | Iterator pointing to end of set. |
|
virtual |
Display the nonlinear function.
Reimplemented from Minotaur::NonlinearFunction.