-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperiodic1.py
30 lines (28 loc) · 1.05 KB
/
periodic1.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
from entities import Policy, Machine, MaintenanceTask, EpochResult, PeriodicPolicy
from engine import IndustrySim
from tools import e_greedy, NN
import numpy as np
import time
from industry import epoch_length, max_epochs, max_labor, wages, num_machines, job_demand
from industry import delay_penalty, mt_fixed_cost, mt_RF, mt_ttr, mt_labor, beta, age
from industry import compatible_jobs, machine_names1
from industry import machine1
env = IndustrySim(machines=[machine1], epoch_length=epoch_length, max_labor=max_labor,
wages=wages, job_demand=job_demand, delay_penalty=delay_penalty)
start = time.time()
env.reset()
res = EpochResult(None, None, None)
experiments = 300
start = time.time()
avg_obj = 0
for exp in range(experiments):
pp = PeriodicPolicy(machine_names=machine_names1, epoch_interval=10000000, pm_type='HIGH')
for i in range(max_epochs):
epoch_result = env.run_epoch(pp.get_policy())
res = env.get_result()
#print(res)
avg_obj += res.objfun
env.reset()
avg_obj/=experiments
print('Avg obj: '+ str(avg_obj))
print('Took '+str(time.time()-start)+'s')