-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevaluate_json.py
32 lines (25 loc) · 1.13 KB
/
evaluate_json.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from evaluation import evaluation_function
from utils import load_solution, load_problem_data
# Path to the directory where your solutions are stored
solution_directory = './'
# LOAD PROBLEM DATA (once, since the data remains the same)
demand, datacenters, servers, selling_prices = load_problem_data()
# List all JSON solution files in the directory
solution_files = [f for f in os.listdir(solution_directory) if f.endswith('.json')]
# Loop through each solution file and evaluate
for solution_file in solution_files:
# Extract seed number from the file name (e.g., '8761.json')
seed = int(solution_file.split('.')[0])
# Load the solution
solution = load_solution(os.path.join(solution_directory, solution_file))
# Evaluate the solution
score = evaluation_function(solution,
demand,
datacenters,
servers,
selling_prices,
seed=seed,
verbose=1)
# Print the seed and score
print(f'Seed: {seed}, Solution score: {score}')