diff --git a/core/src/allocation.jl b/core/src/allocation.jl index d048146e9..795e29e4e 100644 --- a/core/src/allocation.jl +++ b/core/src/allocation.jl @@ -883,20 +883,20 @@ function set_objective_priority!( add_user_term!(ex, edge_id, objective_type, d, allocation_model) end - # Add flow cost - if objective_type == :linear_absolute - cost_per_flow = 0.5 / length(F) - for flow in F - JuMP.add_to_expression!(ex, cost_per_flow * flow) - end - elseif objective_type == :linear_relative - if demand_max > 0.0 - cost_per_flow = 0.5 / (demand_max * length(F)) - for flow in F - JuMP.add_to_expression!(ex, cost_per_flow * flow) - end - end - end + # # Add flow cost + # if objective_type == :linear_absolute + # cost_per_flow = 0.5 / length(F) + # for flow in F + # JuMP.add_to_expression!(ex, cost_per_flow * flow) # + # end + # elseif objective_type == :linear_relative + # if demand_max > 0.0 + # cost_per_flow = 0.5 / (demand_max * length(F)) + # for flow in F + # JuMP.add_to_expression!(ex, cost_per_flow * flow) # + # end + # end + # end new_objective = JuMP.@expression(problem, ex) JuMP.@objective(problem, Min, new_objective) @@ -1154,7 +1154,7 @@ function allocate!( @debug JuMP.solution_summary(problem) if JuMP.termination_status(problem) !== JuMP.OPTIMAL (; allocation_network_id) = allocation_model - priority = priorities[priority_index] + priority = priorities[priority_idx] error( "Allocation of subnetwork $allocation_network_id, priority $priority coudn't find optimal solution.", ) diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 35632e181..782c2322f 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -96,10 +96,6 @@ end @test objective.terms[F_abs[NodeID(5)]] == 1.0 @test objective.terms[F_abs[NodeID(6)]] == 1.0 - @test objective.terms[F[(NodeID(4), NodeID(6))]] ≈ 0.125 - @test objective.terms[F[(NodeID(1), NodeID(2))]] ≈ 0.125 - @test objective.terms[F[(NodeID(4), NodeID(5))]] ≈ 0.125 - @test objective.terms[F[(NodeID(2), NodeID(4))]] ≈ 0.125 config = Ribasim.Config(toml_path; allocation_objective_type = "linear_relative") model = Ribasim.run(config) @@ -113,10 +109,6 @@ end @test objective.terms[F_abs[NodeID(5)]] == 1.0 @test objective.terms[F_abs[NodeID(6)]] == 1.0 - @test objective.terms[F[(NodeID(4), NodeID(6))]] ≈ 62.585499316005475 - @test objective.terms[F[(NodeID(1), NodeID(2))]] ≈ 62.585499316005475 - @test objective.terms[F[(NodeID(4), NodeID(5))]] ≈ 62.585499316005475 - @test objective.terms[F[(NodeID(2), NodeID(4))]] ≈ 62.585499316005475 end @testitem "Allocation with controlled fractional flow" begin