Skip to content

Commit acf3f11

Browse files
committed
fix: resolve 4 remaining test failures (Pareto regression + empty-vector type dispatch)
- welfare.jl: relax utilitarian_welfare and rawlsian_welfare signatures from AbstractVector{<:Real} to AbstractVector so that empty [] (Vector{Any}) dispatches correctly instead of throwing MethodError - optimization.jl: same relaxation for normalize_scores; fixes @test_throws ArgumentError normalize_scores([]) from MethodError to ArgumentError - optimization.jl: fix Pareto regression in value_score for Welfare without :max_welfare — return raw welfare_val instead of clamping to min(1,max(0,val)); the clamp collapsed all positive welfare scores to 1.0, making distinct solutions (utilities [10.0] vs [5.0]) appear identical and preventing domination detection; now scores differ (10.0 vs 5.0) so dominated() works All tests that pass :max_welfare continue through the normalized path unchanged. These four failures were present when PR #16 was admin-merged without CI green. https://claude.ai/code/session_01PWMMxryCcPrAjJ8tuGvygG
1 parent 02d9e63 commit acf3f11

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/optimization.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@ function value_score(value::Value, state::Dict)::Float64
5757
end
5858
end
5959

60-
# Normalize welfare value to [0,1] using max_welfare from state if provided,
61-
# otherwise clamp the raw value to [0,1].
60+
# Normalize welfare value to [0,1] using max_welfare from state if provided.
61+
# Without max_welfare, return the raw welfare value so callers (e.g. pareto_frontier)
62+
# can compare solutions meaningfully rather than collapsing all positive values to 1.0.
6263
max_welfare = get(state, :max_welfare, nothing)
6364
if !isnothing(max_welfare) && max_welfare > 0.0
6465
return min(1.0, max(0.0, welfare_val / max_welfare))
6566
else
66-
# For egalitarian (negative values mean inequality), map to [0,1]:
67-
# 0.0 = perfect equality, negative = inequality → score = max(0, 1 + welfare_val)
68-
# For utilitarian/rawlsian without max_welfare, clamp to [0,1].
69-
return min(1.0, max(0.0, welfare_val))
67+
return welfare_val
7068
end
7169

7270
elseif value isa Profit
@@ -115,7 +113,7 @@ function weighted_score(values::Vector{<:Value}, state::Dict)::Float64
115113
return weighted_sum / total_weight
116114
end
117115

118-
function normalize_scores(scores::AbstractVector{<:Real})::Vector{Float64}
116+
function normalize_scores(scores::AbstractVector)::Vector{Float64}
119117
if isempty(scores)
120118
throw(ArgumentError("Cannot normalize an empty vector of scores."))
121119
end
@@ -190,4 +188,3 @@ function pareto_frontier(system::Dict, values::AbstractVector{<:Value})::Vector{
190188
# Call the primary pareto_frontier method
191189
return pareto_frontier(solutions, values)
192190
end
193-

src/welfare.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
using Statistics
55

6-
function utilitarian_welfare(utilities::AbstractVector{<:Real})::Float64
6+
function utilitarian_welfare(utilities::AbstractVector)::Float64
77
isempty(utilities) && return 0.0 # Return 0.0 for empty utility vector
88
return sum(utilities)
99
end
1010

11-
function rawlsian_welfare(utilities::AbstractVector{<:Real})::Float64
11+
function rawlsian_welfare(utilities::AbstractVector)::Float64
1212
isempty(utilities) && error("Cannot compute Rawlsian welfare for an empty utility vector.")
1313
return minimum(utilities)
1414
end
@@ -190,4 +190,3 @@ function verify_value(value::Safety, proof::Dict)::Bool
190190

191191
return verified
192192
end
193-

0 commit comments

Comments
 (0)