MCPcopy Create free account
hub / github.com/ElementsProject/lightning / combine_cost_function

Function combine_cost_function

plugins/renepay/mcf.c:578–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576}
577
578static void combine_cost_function(
579 const struct linear_network* linear_network,
580 struct residual_network *residual_network,
581 s64 mu)
582{
583 for(struct arc arc = {0};arc.idx < linear_network->max_num_arcs; ++arc.idx)
584 {
585 if(arc_tail(linear_network,arc)==INVALID_INDEX)
586 continue;
587
588 const s64 pcost = linear_network->arc_prob_cost[arc.idx],
589 fcost = linear_network->arc_fee_cost[arc.idx];
590
591 const s64 combined = pcost==INFINITE || fcost==INFINITE ? INFINITE :
592 mu*fcost + (MU_MAX-1-mu)*pcost;
593
594 residual_network->cost[arc.idx]
595 = mu==0 ? pcost :
596 (mu==(MU_MAX-1) ? fcost : combined);
597 }
598}
599
600static void linear_network_add_adjacenct_arc(
601 struct linear_network *linear_network,

Callers 1

minflowFunction · 0.70

Calls 1

arc_tailFunction · 0.70

Tested by

no test coverage detected