Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the incomplete last period's weight to 1 #24

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function find_period_weights(
incomplete_period_weight = nothing
else
complete_period_weight = 1.0
incomplete_period_weight = last_period_duration / period_duration
incomplete_period_weight = 1.0
end
return complete_period_weight, incomplete_period_weight
end
Expand Down
4 changes: 2 additions & 2 deletions test/test-cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ end
clustering_result =
find_representative_periods(clustering_data, 2; method = :k_means, init = :kmcen)

clustering_result.weight_matrix == [1.0 0.0; 0.0 0.5]
clustering_result.weight_matrix == [1.0 0.0; 0.0 1.0]
end

@test begin
Expand Down Expand Up @@ -172,7 +172,7 @@ end
clustering_result =
find_representative_periods(clustering_data, 2; method = :k_medoids, init = :kmcen)

clustering_result.weight_matrix == [1.0 0.0; 0.0 0.5]
clustering_result.weight_matrix == [1.0 0.0; 0.0 1.0]
end

@test begin
Expand Down
2 changes: 1 addition & 1 deletion test/test-weight-fitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
init = :kmcen,
)
TulipaClustering.fit_rep_period_weights!(clustering_result; weight_type = :convex, niters = 5)
sum(clustering_result.weight_matrix) ≈ 365 / 7 &&
sum(clustering_result.weight_matrix) ≈ round(365 / 7, RoundUp) &&
all(sum(clustering_result.weight_matrix[1:(end - 1), :], dims = 2) .≈ 1.0)
end
end
Expand Down