AbstractUserFunction
Base class for user functions. More...
#include <xpress.hpp>

Public Member Functions |
|
virtual auto | call (int output, std::vector< xpress::objects::Expression > arguments) -> xpress::objects::Expression=0 |
Create an expression that represents a symbolic call to this function. |
|
auto | call (std::vector< xpress::objects::Expression > arguments) -> xpress::objects::Expression |
Create an expression that represents a symbolic call to this function. |
|
virtual auto | evaluate (int output, xpress::SizedArray< double const > const &args) -> double=0 |
Evaluate this function for the given values. |
|
auto | evaluate (xpress::SizedArray< double const > const &args) -> double |
Shorthand for evaluate(1, args) . |
|
auto | getId () -> int |
Get the id for this function. |
|
auto | getName () const -> std::string |
Get the name with which the function was registered. |
|
virtual auto | isMultiOutput () -> bool=0 |
Check whether this is a function that produces more than one value for a single call. |
|
auto | triggerEvalError (std::exception_ptr e) -> void |
Trigger a user function evaluation error with a specific exception. |
|
Detailed Description
Base class for user functions.
You will usually not have to create an instance of this class or its subclasses yourself. Instead the way to create an instance is to use an XPRSProblem
instance as factory:
MapFunction f = prob->nlpAddUserFunction("myf", 0, d -> 2 * d);
That is, you create an instance of MapFunctor
, VecMapFunctor
, MultiMapFunctor
, MapDeltaFunctor
, VecMapDeltaFunctor
, or MultiMapDeltaFunctor
and then pass that to the appropriate overload of nlpAddUserFunction
. This will register the function with the Xpress problem object and return a user function instance that can then be used in the code to build formulas.
- Since
- 44.00
Member Function Documentation
call() [1/2]
|
pure virtual |
Create an expression that represents a symbolic call to this function.
- Parameters
-
output If this is a multi-output function then this specifies which output to select. Note that the first output has index 1! arguments Arguments for the function call.
- Returns
- The expression representing a call to this function.
- Since
- 44.00
Implemented in xpress::XPRSProblem::MapDeltaFunction, xpress::XPRSProblem::MapFunction, xpress::XPRSProblem::MultiMapDeltaFunction, xpress::XPRSProblem::MultiMapFunction, xpress::XPRSProblem::VecMapDeltaFunction, and xpress::XPRSProblem::VecMapFunction.
call() [2/2]
|
inline |
Create an expression that represents a symbolic call to this function.
Shorthand for call(1, arguments)
.
- Parameters
-
arguments Arguments to function call.
- Returns
- The expression.
- Since
- 44.00
evaluate() [1/2]
|
pure virtual |
Evaluate this function for the given values.
- Parameters
-
output Output selector. In case the function returns multiple outputs then this selects which of them to return. Otherwise this argument is ignored. Note that the first output has index 1! args Arguments for the function call.
- Returns
- The result.
- Since
- 44.00
Implemented in xpress::XPRSProblem::MapDeltaFunction, xpress::XPRSProblem::MapFunction, xpress::XPRSProblem::MultiMapDeltaFunction, xpress::XPRSProblem::MultiMapFunction, xpress::XPRSProblem::VecMapDeltaFunction, and xpress::XPRSProblem::VecMapFunction.
evaluate() [2/2]
|
inline |
Shorthand for evaluate(1, args)
.
- Parameters
-
args Arguments for the function call.
- Returns
- The result.
- Since
- 44.00
getId()
|
inline |
Get the id for this function.
The id is used to identify this function in formulas that are specified as token/value arrays.
- Returns
- This function's id.
- Since
- 44.00
getName()
|
inline |
Get the name with which the function was registered.
- Returns
- This function's name.
- Since
- 44.00
isMultiOutput()
|
pure virtual |
Check whether this is a function that produces more than one value for a single call.
- Returns
-
true
if the function has more than one output,false
otherwise.
- Since
- 44.00
Implemented in xpress::XPRSProblem::MapDeltaFunction, xpress::XPRSProblem::MapFunction, xpress::XPRSProblem::MultiMapDeltaFunction, xpress::XPRSProblem::MultiMapFunction, xpress::XPRSProblem::VecMapDeltaFunction, and xpress::XPRSProblem::VecMapFunction.
triggerEvalError()
|
inline |
Trigger a user function evaluation error with a specific exception.
Captures e
, stops the optimization and re-raises e
when the call to the current optimization function returns. If this function is called more than once for a single invocation of an optimization function then only the exception from the first call is captured/re-raised.
- Parameters
-
e The exception that caused the user function to fail.
- Since
- 44.00
The documentation for this class was generated from the following file:
- xpress.hpp
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.