-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add new tests for seven modules. Include GH workflow. #563
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #563 +/- ##
==========================================
Coverage ? 40.83%
==========================================
Files ? 126
Lines ? 6482
Branches ? 0
==========================================
Hits ? 2647
Misses ? 3835
Partials ? 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. My comments are mostly cosmetic, except for the possible interactions with Gabe's commerical-solver-use PR (see test/utilities.jl). Approving because I think this should still work.
version: | ||
- "1.6" | ||
- "1.7" | ||
- "1.8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to ensure we're testing on 1.9 (though I guess this is covered by 1
for "latest"?)
There's some new features in 1.9 that might motivate us to stop supporting older versions in GenX v0.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, '1'
ensures we're testing on the latest stable release. We could also keep only the current stable release ('1'
), and the long-term support (LTS
) release (right now, v1.6.7) as other packages do.
.github/workflows/ci.yml
Outdated
git config --local user.name lbonaldo | ||
git config --local user.email "[email protected]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of random, but I'm a bit surprised to see your name here.
I had thought maybe we had a project-wide github account?
Project.toml
Outdated
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" | ||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
|
||
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 points for alphabetizing our dependencies! 🎉
test/Electrolyzer/highs_settings.yml
Outdated
# HiGHS Solver Parameters | ||
# Common solver settings | ||
Feasib_Tol: 1.0e-04 # Primal feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07] | ||
Optimal_Tol: 1.0e-04 # Dual feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07] | ||
TimeLimit: 1.0e23 # Time limit # [type: double, advanced: false, range: [0, inf], default: inf] | ||
Pre_Solve: on # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"] | ||
Method: ipm #HiGHS-specific solver settings # Solver option: "simplex", "choose" or "ipm" # [type: string, advanced: false, default: "choose"] | ||
|
||
#highs-specific solver settings | ||
|
||
# run the crossover routine for ipx | ||
# [type: string, advanced: "on", range: {"off", "on"}, default: "off"] | ||
run_crossover: "on" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit surprised to see highs_settings.yml
in the same folder as the rest of the case. And where is genx_settings.yml
? Usually these are both in a Settings
subfolder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay I think I see how you're doing this below, by using a run_genx_case_testing function. Cool!
test/test_methodofmorris.jl
Outdated
|
||
# Define test inputs | ||
genx_setup = Dict( | ||
"MacOrWindows" => "Mac", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MaxOrWindows is obsolete and can be removed
test/test_methodofmorris.jl
Outdated
"ModelingToGenerateAlternatives" => 0, | ||
"ModelingtoGenerateAlternativeSlack" => 0.1, | ||
"ModelingToGenerateAlternativeIterations" => 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably these can be removed if they're not being used (since the default is to have them be zero anyway)
test/test_threezones.jl
Outdated
|
||
include(joinpath(@__DIR__, "utilities.jl")) | ||
|
||
obj_true = 6.9602085499e+03 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you get these numbers? Did you set the solver tolerance to be super super low?
If not, probably we should truncate to the number of digits used by that solver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run the example several times and check if the value of the objective function was stable.
You're right, thanks, I will round them to match the tolerance (I'm using Optimal_Tol: 1.0e-05
)
test/utilities.jl
Outdated
function run_genx_case_simple_testing(test_path::AbstractString, genx_setup::Dict) | ||
# Run the case | ||
OPTIMIZER = configure_solver(genx_setup["Solver"], test_path) | ||
inputs = load_inputs(genx_setup, test_path) | ||
EP = generate_model(genx_setup, inputs, OPTIMIZER) | ||
EP, _ = solve_model(EP, genx_setup) | ||
return EP, inputs, OPTIMIZER | ||
end | ||
|
||
function run_genx_case_multistage_testing(test_path::AbstractString, genx_setup::Dict) | ||
# Run the case | ||
OPTIMIZER = configure_solver(genx_setup["Solver"], test_path) | ||
|
||
model_dict = Dict() | ||
inputs_dict = Dict() | ||
|
||
for t in 1:genx_setup["MultiStageSettingsDict"]["NumStages"] | ||
# Step 0) Set Model Year | ||
genx_setup["MultiStageSettingsDict"]["CurStage"] = t | ||
|
||
# Step 1) Load Inputs | ||
inpath_sub = joinpath(test_path, string("Inputs_p", t)) | ||
inputs_dict[t] = load_inputs(genx_setup, inpath_sub) | ||
inputs_dict[t] = configure_multi_stage_inputs(inputs_dict[t], genx_setup["MultiStageSettingsDict"], genx_setup["NetworkExpansion"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might consider how this will work with Gabe's optimizer-separating PR.
Spur of the moment idea:
For both, we might consider using keyword arguments. Something like
run_genx_case(path; optimizer:All=HiGHS.Optimizer, genx_setup::Union{nothing,Dict})
and then only what is not already supplied could be loaded.
test/utilities.jl
Outdated
if !isdir(joinpath("Logs")) | ||
mkdir(joinpath("Logs")) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just do "Logs" without joinpath
bf40ed4
to
deacbab
Compare
Period_Index,Rep_Period,Rep_Period_Index | ||
1,72,2 | ||
2,72,2 | ||
3,72,2 | ||
4,72,2 | ||
5,72,2 | ||
6,72,2 | ||
7,72,2 | ||
8,72,2 | ||
9,72,2 | ||
10,72,2 | ||
11,72,2 | ||
12,72,2 | ||
13,72,2 | ||
14,72,2 | ||
15,72,2 | ||
16,72,2 | ||
17,72,2 | ||
18,72,2 | ||
19,72,2 | ||
20,72,2 | ||
21,72,2 | ||
22,72,2 | ||
23,72,2 | ||
24,72,2 | ||
25,72,2 | ||
26,72,2 | ||
27,27,1 | ||
28,72,2 | ||
29,72,2 | ||
30,72,2 | ||
31,72,2 | ||
32,72,2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Period_map file seems odd. Is this 365 days being represented by 5 days?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
593e27a
to
ff2a8fe
Compare
ff2a8fe
to
3cc5dea
Compare
This PR adds seven more tests to GenX: three-zone, multi-stage, electrolyzer, VRE+storage, piecewise_fuel+CO2, TDR, and Method of Morris. The tests are passed if the value of the objective function is consistent over time (up to the tolerance of the solver). The tests for the TDR validate the clustering by computing the rand index and the mutual information and comparing the output files. For the Method of Morris module, we are testing if the module is correctly built and if the output is consistent over time.
Description
This PR adds seven more tests that are executed whenever a pull request is
opened
,synchronize
, andreopened
, or at every push targetingmain
ordevelop.
The tests are:test_threezones.jl
: tests GenX over three zones and five representative days;test_multistage.jl
: tests the multistage module over a single zone and five representative days;test_electrolyzer.jl
: tests the electrolyzer module over five representative days;test_VREStor.jl
: tests VRE and storage over 24 hours;test_piecewisefuel_CO2.jl
: tests the piecewise fuel CO2 module over 24 hours;test_time_domain_reduction.jl
: tests the TDR module;test_methodofmorris.jl
: tests the Method of Morris module.For the first five cases, the tests are passed if the value of the objective function is consistent over time (up to the tolerance of the solver). The results are stored in a log folder updated in a separate repository (
GenXProject/GenX-testlog.git
).The tests in
test_time_domain_reduction.jl
validate the clustering for the TDR module by computing the rand index and the mutual information and by comparing the output files.For the
Method of Morris
module, we are testing if the module is correctly built, and if the output is consistent over time.I'd appreciate any critiques or suggestions on how to improve these tests.
What type of PR is this?
Checklist
How this can be tested
After checking out
develop
, enter the package manager and runtest
ortest GenX
. The tests should run automatically.Post-approval checklist for GenX core developers
After the PR is approved