Skip to content

Commit

Permalink
generation for ts OK
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Mar 18, 2024
1 parent 084b625 commit bde0deb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions scripts/antares_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def remove_outputs(study_path):
for f in files:
shutil.rmtree(f)

def launch_solver(solver_path, study_path, use_ortools = False, ortools_solver = "sirius", named_mps_problems = False, ts_generator = False):
def launch_solver(solver_path, study_path, use_ortools = False, ortools_solver = "sirius", named_mps_problems = False, ts_generator_path = ""):
# Clean study output
remove_outputs(study_path)

Expand All @@ -62,23 +62,23 @@ def launch_solver(solver_path, study_path, use_ortools = False, ortools_solver =
command.append('--ortools-solver='+ortools_solver)
if named_mps_problems:
command.append('--named-mps-problems')
if ts_generator:
cluster_to_gen_file = open(path / "clustersToGen.txt", 'r')
if ts_generator_path != "":
cluster_to_gen_file = open(study_path / "clustersToGen.txt", 'r')
cluster_to_gen = cluster_to_gen_file.readline().rstrip() # remove new line char
cluster_to_gen_file.close()
command = [solver_path_full, cluster_to_gen, str(study_path)]
command = [ts_generator_path, cluster_to_gen, str(study_path)]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None)
stdout, stderr = process.communicate()
exit_code = process.wait()

return (exit_code == 0)

def generate_reference_values(solver_path, path, use_ortools, ortools_solver, named_mps_problems, ts_generator):
def generate_reference_values(solver_path, path, use_ortools, ortools_solver, named_mps_problems, ts_generator_path):

enable_study_output(path, True)

result = launch_solver(solver_path,path, use_ortools, ortools_solver, named_mps_problems, ts_generator)
result = launch_solver(solver_path,path, use_ortools, ortools_solver, named_mps_problems, ts_generator_path)

output_path = path / 'output'
list_dir = list_directories(output_path)
Expand Down
9 changes: 5 additions & 4 deletions scripts/generate_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def find_binary(path, binary_name):
solver_path = find_binary(args.solver, "solver")
print(f"Found solver {solver_path}")

tsgenerator_path = find_binary(args.solver, "ts-generator")
print(f"Found ts-generator {tsgenerator_path}")
ts_generator_path = find_binary(args.solver, "ts-generator")
print(f"Found ts-generator {ts_generator_path}")

studies = antares_utils.list_studies(root)

Expand All @@ -55,11 +55,12 @@ def solver_config(study_name):
# Do we need named MPS problems ?
named_mps_problems = (study.parent.name == 'valid-named-mps')
# Are we testing the time series generator ?
ts_generator = (study.parent.name == 'ts-generator')
if study.parent.name != 'ts-generator':
ts_generator_path = ""
# What optimization solver to use ?
(opt_solver, use_ortools) = solver_config(study.parent.name)

result = antares_utils.generate_reference_values(solver_path, study, use_ortools, opt_solver, named_mps_problems, ts_generator)
result = antares_utils.generate_reference_values(solver_path, study, use_ortools, opt_solver, named_mps_problems, ts_generator_path)
ret.append(result)
print('OK' if result else 'KO')

Expand Down

0 comments on commit bde0deb

Please sign in to comment.