Skip to content

Add capacity bidding and consumer landed costs#2

Merged
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator
Apr 7, 2026
Merged

Add capacity bidding and consumer landed costs#2
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator

Conversation

@wnj00524
Copy link
Copy Markdown
Owner

@wnj00524 wnj00524 commented Apr 7, 2026

No description provided.

@wnj00524 wnj00524 merged commit b6712ff into master Apr 7, 2026
0 of 2 checks passed
@wnj00524 wnj00524 deleted the codex/wpf-network-simulator branch April 7, 2026 12:47
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces edge capacity modeling and a capacity bidding system to the network simulator. Key changes include UI enhancements to display capacity and consumer costs, updated data models, and a significant update to the simulation engine to handle shared edge capacities and bid-based routing priorities. Feedback focuses on performance bottlenecks in the simulation logic, specifically the redundant execution of Dijkstra's algorithm within the main simulation loop and the inefficiency of calculating routes per producer-consumer pair rather than per producer. Additionally, there is a recommendation to deduplicate the traffic name ordering logic shared between the simulation engine and the main view model.

{
notes.Add("No producer nodes were defined for this traffic type.");
var nextCandidate = contexts
.SelectMany(context => BuildCandidateRoutes(context, adjacency, remainingCapacityByEdgeId))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The simulation loop is highly inefficient. It recalculates all possible routes for all traffic types in every iteration of the while loop, only to select the single best candidate and discard the rest. This results in a massive number of redundant Dijkstra calculations. For a network with $T$ traffic types, $P$ producers, and $C$ consumers, this approach performs $O(T \cdot P \cdot C)$ Dijkstra executions per allocation step. Consider caching the candidate routes and only updating those that are invalidated by the previous allocation (e.g., routes containing an edge whose capacity was changed).

Comment on lines +277 to 280
foreach (var producerNodeId in context.Supply.Where(pair => pair.Value > Epsilon).Select(pair => pair.Key))
{
foreach (var consumerNodeId in demand.Where(pair => pair.Value > Epsilon).Select(pair => pair.Key))
foreach (var consumerNodeId in context.Demand.Where(pair => pair.Value > Epsilon).Select(pair => pair.Key))
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

BuildCandidateRoutes iterates over every producer-consumer pair and calls FindBestRoute (Dijkstra) for each. It is much more efficient to run Dijkstra once per producer to find the shortest paths to all consumers in the network simultaneously. This would reduce the complexity from $O(P \times C)$ to $O(P)$ Dijkstra executions per traffic type.

}
}

private static List<string> GetOrderedTrafficNames(NetworkModel network)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The method GetOrderedTrafficNames is duplicated here and in MainWindowViewModel.cs. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, this logic should be moved to a shared service or a static utility class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant