diff --git a/Example_Systems/SmallNewEngland/OneZone/Run.jl b/Example_Systems/SmallNewEngland/OneZone/Run.jl index bd348e576..15bf95922 100644 --- a/Example_Systems/SmallNewEngland/OneZone/Run.jl +++ b/Example_Systems/SmallNewEngland/OneZone/Run.jl @@ -105,3 +105,5 @@ outpath_GenX = write_outputs(EP, outpath, mysetup, myinputs) if mysetup["ModelH2"] == 1 write_HSC_outputs(EP, outpath_GenX, mysetup, myinputs) end + +compare_results(outpath_GenX, joinpath(case_dir, "Results")) diff --git a/Example_Systems/SmallNewEngland/ThreeZones/Run.jl b/Example_Systems/SmallNewEngland/ThreeZones/Run.jl index bd348e576..15bf95922 100644 --- a/Example_Systems/SmallNewEngland/ThreeZones/Run.jl +++ b/Example_Systems/SmallNewEngland/ThreeZones/Run.jl @@ -105,3 +105,5 @@ outpath_GenX = write_outputs(EP, outpath, mysetup, myinputs) if mysetup["ModelH2"] == 1 write_HSC_outputs(EP, outpath_GenX, mysetup, myinputs) end + +compare_results(outpath_GenX, joinpath(case_dir, "Results")) diff --git a/src/configure_solver/configure_highs.jl b/src/configure_solver/configure_highs.jl index 3abd0bd80..2a8382147 100644 --- a/src/configure_solver/configure_highs.jl +++ b/src/configure_solver/configure_highs.jl @@ -31,7 +31,7 @@ The HiGHS optimizer instance is configured with the following default parameters TimeLimit: Inf # Time limit # [type: double, advanced: false, range: [0, inf], default: inf] Pre_Solve: choose # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"] Method: ipm #choose #HiGHS-specific solver settings # Solver option: "simplex", "choose" or "ipm" # [type: string, advanced: false, default: "choose"] In order to run a case when the UCommit is set to 1, i.e. MILP instance, set the Method to choose - + # HiGHS-specific solver settings # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"] @@ -447,7 +447,7 @@ function configure_highs(solver_settings_path::String) if (haskey(solver_settings, "parallel")) Myparallel = solver_settings["parallel"] end - Myrun_crossover = false + Myrun_crossover = "off" if (haskey(solver_settings, "run_crossover")) Myrun_crossover = solver_settings["run_crossover"] end @@ -708,10 +708,10 @@ function configure_highs(solver_settings_path::String) if (haskey(solver_settings, "allowed_cost_scale_factor")) Myallowed_cost_scale_factor = solver_settings["allowed_cost_scale_factor"] end - Mysimplex_dualise_strategy = -1 - if (haskey(solver_settings, "simplex_dualise_strategy")) - Mysimplex_dualise_strategy = solver_settings["simplex_dualise_strategy"] - end + # Mysimplex_dualise_strategy = -1 + # if (haskey(solver_settings, "simplex_dualise_strategy")) + # Mysimplex_dualise_strategy = solver_settings["simplex_dualise_strategy"] + # end Mysimplex_permute_strategy = -1 if (haskey(solver_settings, "simplex_permute_strategy")) Mysimplex_permute_strategy = solver_settings["simplex_permute_strategy"] @@ -897,7 +897,7 @@ function configure_highs(solver_settings_path::String) "cost_scale_factor" => Mycost_scale_factor, "allowed_matrix_scale_factor" => Myallowed_matrix_scale_factor, "allowed_cost_scale_factor" => Myallowed_cost_scale_factor, - "simplex_dualise_strategy" => Mysimplex_dualise_strategy, + # "simplex_dualise_strategy" => Mysimplex_dualise_strategy, "simplex_permute_strategy" => Mysimplex_permute_strategy, "max_dual_simplex_cleanup_level" => Mymax_dual_simplex_cleanup_level, "max_dual_simplex_phase1_cleanup_level" => diff --git a/src/core/compare_results.jl b/src/core/compare_results.jl index 3570fad37..1d2d41110 100644 --- a/src/core/compare_results.jl +++ b/src/core/compare_results.jl @@ -19,9 +19,26 @@ received this license file. If not, see . This function compares the contents of two directories and returns a summary file of the differences """ -function compare_results(path1::AbstractString, path2::AbstractString, output_filename::AbstractString="summary.txt") - lines_to_write = compare_dir(path1, path2) - print_comparison(lines_to_write, output_filename) +function compare_results( + path1::AbstractString, + path2::AbstractString, + output_filename::AbstractString = "summary.txt", +) + ## Check that the paths are valid + if !isdir(path1) || !isdir(path2) || path1 == path2 + println("One or Both of the Paths Doesn't Exist or They are the Same") + else + lines_to_write, identical_structure, identical_contents = compare_dir(path1, path2) + if identical_structure + println("Structure of $path1 and $path2 is Identical") + end + if identical_contents + println("Contents of $path1 and $path2 is Identical") + end + if !identical_structure || !identical_contents + print_comparison(lines_to_write, output_filename) + end + end end @doc raw""" @@ -29,8 +46,11 @@ end Takes a string array of differences between two directories and prints them to a file """ -function print_comparison(lines_to_write::Array{Any,1}, output_filename::AbstractString="summary.txt") - summary_file = open(output_filename, "w") +function print_comparison( + lines_to_write::Array{Any,1}, + output_filename::AbstractString = "summary.txt", +) + summary_file = open(output_filename, "a") write(summary_file, join(lines_to_write)) close(summary_file) end @@ -40,13 +60,17 @@ end Compares the contents of two directories and returns a string array of the differences """ -function compare_dir(path1::AbstractString, path2::AbstractString, inset::String="") +function compare_dir(path1::AbstractString, path2::AbstractString, inset::String = "") # Get the list of files in each directory - files1 = readdir(path1) - files2 = readdir(path2) + files1 = filter(x -> !any(occursin.(["log", "lp", "txt"], x)), readdir(path1)) + files2 = filter(x -> !any(occursin.(["log", "lp", "txt"], x)), readdir(path2)) dirname1 = split(path1, "\\")[end] dirname2 = split(path2, "\\")[end] + ## Flag denoting whether the structure and contents are identical + identical_structure = true + identical_contents = true + # Get the list of files that are in both directories common_files = intersect(files1, files2) @@ -55,7 +79,7 @@ function compare_dir(path1::AbstractString, path2::AbstractString, inset::String only2 = setdiff(files2, common_files) # Create a summary file - + lines_to_write = [] push!(lines_to_write, "$(inset)Comparing the following directories:\n") push!(lines_to_write, "$(inset)--- $dirname1 ---\n") @@ -67,17 +91,22 @@ function compare_dir(path1::AbstractString, path2::AbstractString, inset::String push!(lines_to_write, "$(inset)Files in $dirname1 but not in $dirname2:\n") push!(lines_to_write, join([inset, join(only1, "\n$inset")])) push!(lines_to_write, "\n") + identical_structure = false end if length(only2) > 0 push!(lines_to_write, "$(inset)Files in $dirname2 but not in $dirname1:\n") push!(lines_to_write, join([inset, join(only2, "\n$inset")])) push!(lines_to_write, "\n") + identical_structure = false end - if length(only1) == 0 && length(only2) ==0 - push!(lines_to_write, "$(inset)Both directories contain the same files and subdirectories\n") + if length(only1) == 0 && length(only2) == 0 + push!( + lines_to_write, + "$(inset)Both directories contain the same files and subdirectories\n", + ) end push!(lines_to_write, "\n") - + common_files_matching = [] common_files_diff = [] subdirs = [] @@ -108,6 +137,7 @@ function compare_dir(path1::AbstractString, path2::AbstractString, inset::String if length(common_files_diff) > 0 push!(lines_to_write, join([inset, "Mismatched result files: \n"])) push!(lines_to_write, join([inset, join(common_files_diff, "\n$inset")])) + identical_contents = false else push!(lines_to_write, join([inset, "No mismatched result files"])) end @@ -118,13 +148,23 @@ function compare_dir(path1::AbstractString, path2::AbstractString, inset::String push!(lines_to_write, join([inset, "Sub-directories"])) push!(lines_to_write, "\n") for subdir in subdirs - lines_to_write = [lines_to_write; compare_dir(joinpath(path1, subdir), joinpath(path2, subdir), join([inset, " "]))] + lines_to_write = [ + lines_to_write + first( + compare_dir( + joinpath(path1, subdir), + joinpath(path2, subdir), + join([inset, " "]), + ), + ) + ] end + push!(lines_to_write, "\n") end end - return lines_to_write + return lines_to_write, identical_structure, identical_contents end - + @doc raw""" filecmp_byte(path1::AbstractString, path2::AbstractString)