In [32]:
%matplotlib inline
import LogReader as lr
import LogDataStructures as ls
fieldopt_path = "/home/einar/Documents/GitHub/PCG/FieldOpt/"
output_dir_path = "/home/einar/fieldopt_output/"
reader = lr.LogReader(output_dir_path)
case_container = ls.CaseContainer(reader.case_log, reader.property_uuid_name_map)
optimizer = ls.Optimizer(reader.optimization_log, case_container)
simulator = ls.Simulator(reader.simulation_log)
production_data = ls.ProductionData(reader.production_data_log)
case_base = case_container.evaluated_cases[0]
case_tentative_best = optimizer.best_case_pr_iteration[-1]
case_latest = case_container.evaluated_cases[-1]
In [33]:
print('Current iteration:\t', optimizer.current_iteration)
print('Current step length:\t', optimizer.current_step_length)
print('Number of evaluated cases simulated in total:\t\t', optimizer.number_of_evaluated_cases)
print('Number of cases simulated this iteration:\t\t', optimizer.number_of_evaluated_cases_in_iteration)
print('Number of cases yet to be simulated this iteration:\t', optimizer.number_of_queued_cases_in_iteration)
In [34]:
from matplotlib import pyplot as plt
fig_ofv = plt.figure()
fig_ofv.set_size_inches(10,6)
ax_ofv = fig_ofv.add_subplot(111)
ax_ofv.plot([i+1 for i in range(len(optimizer.best_case_pr_iteration))],
[c.objective_function_value for c in optimizer.best_case_pr_iteration])
ax_ofv.set_xlabel('Iteration')
ax_ofv.set_ylabel('Objective function value')
ax_ofv.set_title('Objective function values per iteration')
print('Iteration\tObjective function value')
for i in range(len(optimizer.best_case_pr_iteration)):
print (i+1, '\t\t', optimizer.best_case_pr_iteration[i].objective_function_value)
In [36]:
from matplotlib import pyplot as plt
fig_sim_exec_time = plt.figure()
fig_sim_exec_time.set_size_inches(10,6)
ax_sim_exec_time = fig_sim_exec_time.add_subplot(121)
ax_sim_exec_time.plot([i+1 for i in range(len(simulator.durations))],
simulator.durations)
ax_sim_exec_time.set_xlabel('Simulation #')
ax_sim_exec_time.set_ylabel('Execution time [seconds]')
ax_sim_exec_time = fig_sim_exec_time.add_subplot(122)
ax_sim_exec_time.semilogy([i+1 for i in range(len(simulator.durations))],
simulator.durations)
ax_sim_exec_time.set_xlabel('Simulation #')
ax_sim_exec_time.set_ylabel('log(Execution time [seconds])')
import numpy as np
simulator_durations = np.array(simulator.durations)
print('Min:\t', simulator_durations.min(), 's')
print('Max:\t', simulator_durations.max(), 's')
print('Median:\t', np.median(simulator_durations), 's')
print('Mean:\t', simulator_durations.mean(), 's')
In [31]:
from matplotlib import pyplot as plt
fig_result_history = plt.figure()
fig_result_history.set_size_inches(10,6)
ax_result_history = fig_result_history.add_subplot(111)
for case_id in production_data.time:
ax_result_history.plot(production_data.time[case_id], production_data.fopt[case_id], 'r')
#ax_result_history.plot(production_data.time[case_id], production_data.fwpt[case_id], 'b')
#ax_result_history.plot(production_data.time[case_id], production_data.fgpt[case_id], 'g')
In [31]: