#include <netoptim/network_oracle.hpp>
template<typename Graph, typename Mapping, typename Fn>
NetworkOracle class
Oracle for Parametric Network Problems.
| Template parameters | |
|---|---|
| Graph | Type of the directed graph |
| Mapping | Type of vertex potential mapping |
| Fn | Type of the constraint function h |
This class implements a separation oracle for network feasibility problems. It uses negative cycle detection to check feasibility and generate cutting planes when violations are found.
The oracle maintains:
- A reference to the graph structure
- A mapping of vertex potentials (utx)
- A negative cycle finder for violation detection
- A function h that evaluates edge constraints
Constructors, destructors, conversion operators
- NetworkOracle(const Graph& gra, Mapping& utx, Fn h)
- Construct a new network oracle object.
- NetworkOracle(const NetworkOracle&) defaulted explicit
- Construct a new network oracle object.
Public functions
-
template<typename Num>auto update(const Num& gamma) -> void -> auto
- Update the oracle with a new parameter value.
-
template<typename Arr>auto assess_feas(const Arr& xval) -> std::optional< std::pair< Arr, double > > -> auto
- Assess feasibility and generate cutting plane if needed.
-
template<typename Arr>auto operator()(const Arr& xvar) -> std::optional< std::pair< Arr, double > > -> auto
- Function call operator for cutting plane methods.
Function documentation
template<typename Graph, typename Mapping, typename Fn>
NetworkOracle<Graph, Mapping, Fn>:: NetworkOracle(const Graph& gra,
Mapping& utx,
Fn h)
Construct a new network oracle object.
| Parameters | |
|---|---|
| gra in | a directed graph (V, E) representing the network |
| utx in/out | vertex potential mapping (updated during operation) |
| h in | function for constraint evaluation and gradient computation |
template<typename Graph, typename Mapping, typename Fn>
template<typename Num>
auto NetworkOracle<Graph, Mapping, Fn>:: update(const Num& gamma) -> void
Update the oracle with a new parameter value.
| Parameters | |
|---|---|
| gamma in | the new parameter value (best-so-far optimal value) |
This method updates the internal constraint function with a new parameter value, typically used in parametric optimization where the constraints depend on a parameter that changes during the algorithm.
template<typename Graph, typename Mapping, typename Fn>
template<typename Arr>
auto NetworkOracle<Graph, Mapping, Fn>:: assess_feas(const Arr& xval) -> std::optional< std::pair< Arr, double > >
Assess feasibility and generate cutting plane if needed.
| Template parameters | |
|---|---|
| Arr | Type of the input array/vector |
| Parameters | |
| xval in | input values to be assessed for feasibility |
| Returns | std::optional<std::pair<Arr, double>> Empty if feasible, otherwise a pair containing gradient and function value for cutting plane |
This is the main oracle method that checks if the current point xval is feasible with respect to the network constraints. If infeasible, it returns a cutting plane (gradient and function value) that separates the infeasible point from the feasible region.
The method works by:
- Computing edge weights using the constraint function
- Searching for negative cycles using these weights
- If found, computing the gradient and function value for the cut
- Returning the cutting plane or empty if feasible
template<typename Graph, typename Mapping, typename Fn>
template<typename Arr>
auto NetworkOracle<Graph, Mapping, Fn>:: operator()(const Arr& xvar) -> std::optional< std::pair< Arr, double > >
Function call operator for cutting plane methods.
| Template parameters | |
|---|---|
| Arr | Type of the input array/vector |
| Parameters | |
| xvar in | input variables to be assessed |
| Returns | std::optional<std::pair<Arr, double>> Same as assess_feas |
This operator makes the oracle callable, which is convenient for use with cutting plane algorithms. It simply forwards to the assess_feas method.