Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::MCF_LP_Solver< Net > Class Template Reference

Multi-commodity flow solver using LP formulation. More...

#include <tpl_multicommodity.H>

Collaboration diagram for Aleph::MCF_LP_Solver< Net >:
[legend]

Public Types

using Node = typename Net::Node
 
using Arc = typename Net::Arc
 
using Flow_Type = typename Net::Flow_Type
 
using Result = MCF_Result< Flow_Type >
 

Public Member Functions

 MCF_LP_Solver (Net &network)
 Construct solver for a network.
 
Result solve ()
 Solve the multi-commodity flow problem.
 
void print_formulation (size_t max_constraints=10) const
 Print LP formulation (for debugging).
 

Private Member Functions

size_t var_index (size_t k, size_t arc_idx) const
 

Private Attributes

Net & net
 
DynMapTree< Arc *, size_t > arc_to_idx
 

Detailed Description

template<class Net>
class Aleph::MCF_LP_Solver< Net >

Multi-commodity flow solver using LP formulation.

Solves the MCF problem by formulating it as a linear program and using the Revised Simplex algorithm.

LP Formulation

Variables: x_{ij}^k for each arc (i,j) and commodity k Total: K * |E| variables

Constraints:

  1. Flow conservation at each node for each commodity: K * |V|
  2. Capacity constraints on each arc: |E|

Total constraints: K * |V| + |E|

Template Parameters
NetNetwork type (should be MCF_Graph or compatible).
See also
MCF_Graph RevisedSimplex

Definition at line 457 of file tpl_multicommodity.H.

Member Typedef Documentation

◆ Arc

template<class Net >
using Aleph::MCF_LP_Solver< Net >::Arc = typename Net::Arc

Definition at line 461 of file tpl_multicommodity.H.

◆ Flow_Type

template<class Net >
using Aleph::MCF_LP_Solver< Net >::Flow_Type = typename Net::Flow_Type

Definition at line 462 of file tpl_multicommodity.H.

◆ Node

template<class Net >
using Aleph::MCF_LP_Solver< Net >::Node = typename Net::Node

Definition at line 460 of file tpl_multicommodity.H.

◆ Result

template<class Net >
using Aleph::MCF_LP_Solver< Net >::Result = MCF_Result<Flow_Type>

Definition at line 463 of file tpl_multicommodity.H.

Constructor & Destructor Documentation

◆ MCF_LP_Solver()

template<class Net >
Aleph::MCF_LP_Solver< Net >::MCF_LP_Solver ( Net &  network)
inlineexplicit

Construct solver for a network.

Parameters
[in]networkThe multi-commodity network to solve.

Definition at line 480 of file tpl_multicommodity.H.

References Aleph::MCF_LP_Solver< Net >::arc_to_idx, Aleph::DynMapTree< Key, Data, Tree, Compare >::insert(), and Aleph::MCF_LP_Solver< Net >::net.

Member Function Documentation

◆ print_formulation()

template<class Net >
void Aleph::MCF_LP_Solver< Net >::print_formulation ( size_t  max_constraints = 10) const
inline

Print LP formulation (for debugging).

Parameters
[in]max_constraintsMaximum constraints to print.

Definition at line 660 of file tpl_multicommodity.H.

References GraphCommon< GT, Node, Arc >::esize(), k, Aleph::MCF_LP_Solver< Net >::net, V, and GraphCommon< GT, Node, Arc >::vsize().

◆ solve()

template<class Net >
Result Aleph::MCF_LP_Solver< Net >::solve ( )
inline

Solve the multi-commodity flow problem.

Formulates and solves the LP using the standard Simplex algorithm. The problem is formulated with equality constraints for flow conservation and inequality constraints for capacity.

Returns
Result structure with status and cost.

Definition at line 496 of file tpl_multicommodity.H.

References Aleph::DynMapTree< Key, Data, Tree, Compare >::append(), Aleph::MCF_LP_Solver< Net >::arc_to_idx, Aleph::MCF_Result< Flow_Type >::commodity_costs, GraphCommon< GT, Node, Arc >::esize(), Aleph::DynMapTree< Key, Data, Tree, Compare >::find(), Aleph::Simplex< T >::get_solution(), Aleph::Simplex< T >::get_stats(), Aleph::DynMapTree< Key, Data, Tree, Compare >::has(), Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::Node_Arc_Iterator::has_curr(), Aleph::MCF_Result< Flow_Type >::Infeasible, Aleph::SimplexStats::iterations, Aleph::MCF_Result< Flow_Type >::iterations, k, Aleph::Simplex< T >::load_solution(), Aleph::MCF_LP_Solver< Net >::net, Aleph::Simplex< T >::objetive_value(), Aleph::MCF_Result< Flow_Type >::Optimal, Aleph::Simplex< T >::prepare_linear_program(), Aleph::Simplex< T >::put_eq_restriction(), Aleph::Simplex< T >::put_objetive_function_coef(), Aleph::Simplex< T >::put_restriction(), row, Aleph::Simplex< T >::set_minimize(), Aleph::Simplex< T >::solve(), Aleph::MCF_Result< Flow_Type >::solve_time_ms, Aleph::MCF_Result< Flow_Type >::status, Aleph::MCF_Result< Flow_Type >::total_cost, Aleph::MCF_Result< Flow_Type >::Unbounded, and Aleph::MCF_LP_Solver< Net >::var_index().

Referenced by Aleph::solve_multicommodity_flow().

◆ var_index()

template<class Net >
size_t Aleph::MCF_LP_Solver< Net >::var_index ( size_t  k,
size_t  arc_idx 
) const
inlineprivate

Member Data Documentation

◆ arc_to_idx

template<class Net >
DynMapTree<Arc*, size_t> Aleph::MCF_LP_Solver< Net >::arc_to_idx
private

◆ net


The documentation for this class was generated from the following file: