Skip to content

Commit 4f063bd

Browse files
committed
askrene: add mcf_refinement to the public API
Changelog-none: askrene: add mcf_refinement to the public API Signed-off-by: Lagrang3 <[email protected]>
1 parent 8f2f2f2 commit 4f063bd

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

plugins/askrene/algorithm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,12 @@ static struct node dijkstra_nearest_sink(const tal_t *ctx,
513513
* algorithm that changes the cost function at every iteration and we need
514514
* to find the MCF every time.
515515
* */
516-
static bool mcf_refinement(const tal_t *ctx,
517-
const struct graph *graph,
518-
s64 *excess,
519-
s64 *capacity,
520-
const s64 *cost,
521-
s64 *potential)
516+
bool mcf_refinement(const tal_t *ctx,
517+
const struct graph *graph,
518+
s64 *excess,
519+
s64 *capacity,
520+
const s64 *cost,
521+
s64 *potential)
522522
{
523523
bool solved = false;
524524
tal_t *this_ctx = tal(ctx, tal_t);

plugins/askrene/algorithm.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,27 @@ bool simple_mcf(const tal_t *ctx, const struct graph *graph,
153153
* @cost: cost per unit of flow */
154154
s64 flow_cost(const struct graph *graph, const s64 *capacity, const s64 *cost);
155155

156+
/* Take an existent flow and find an optimal redistribution:
157+
*
158+
* inputs:
159+
* @ctx: tal context for internal allocation,
160+
* @graph: topological information of the graph,
161+
* @excess: supply/demand of nodes,
162+
* @capacity: residual capacity in the arcs,
163+
* @cost: cost per unit of flow for every arc,
164+
* @potential: node potential,
165+
*
166+
* outputs:
167+
* @excess: all values become zero if there exist a feasible solution,
168+
* @capacity: encodes the resulting flow,
169+
* @potential: the potential that proves the solution using the complementary
170+
* slackness optimality condition.
171+
* */
172+
bool mcf_refinement(const tal_t *ctx,
173+
const struct graph *graph,
174+
s64 *excess,
175+
s64 *capacity,
176+
const s64 *cost,
177+
s64 *potential);
178+
156179
#endif /* LIGHTNING_PLUGINS_ASKRENE_ALGORITHM_H */

0 commit comments

Comments
 (0)