-
Notifications
You must be signed in to change notification settings - Fork 1
/
train.py
66 lines (61 loc) · 1.56 KB
/
train.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from environment.negotiation import NegotiationEnv
from environment.domains import get_domains
from agent.ppo_agent import PPOAgent
from environment.opponents import (
BoulwareAgent,
ConcederAgent,
HardlinerAgent,
LinearAgent,
RandomAgent,
StupidAgent,
CSE3210,
)
# collect domains and opponents for trainig (don't initialise the opponents)
domains = get_domains("environment/domains/train")
opponents = (
# ConcederAgent,
# HardlinerAgent,
# BoulwareAgent,
# LinearAgent,
# RandomAgent,
# StupidAgent,
# CSE3210.Agent2,
CSE3210.Agent3,
CSE3210.Agent7,
CSE3210.Agent11,
CSE3210.Agent14,
CSE3210.Agent18,
CSE3210.Agent19,
CSE3210.Agent22,
CSE3210.Agent24,
CSE3210.Agent25,
# CSE3210.Agent26,
CSE3210.Agent27,
CSE3210.Agent29,
CSE3210.Agent32,
CSE3210.Agent33,
# CSE3210.Agent41,
# CSE3210.Agent43,
CSE3210.Agent50,
# CSE3210.Agent52,
CSE3210.Agent55,
CSE3210.Agent58,
CSE3210.Agent61,
# CSE3210.Agent64,
# CSE3210.Agent67,
# CSE3210.Agent68,
# CSE3210.Agent70,
# CSE3210.Agent78,
)
continue_train = False
if continue_train:
agent = PPOAgent.load("checkpoint.pkl")
else:
agent = PPOAgent()
# create environment and PPO agent
env = NegotiationEnv(domains=domains, opponents=opponents, deadline_ms=10000, seed=42)
# set checkpoint path for intermediate model checkpoints
checkpoint_path = "checkpoint.pkl"
# train and save agent
agent.train(env=env, time_budget_sec=25000, checkpoint_path=checkpoint_path)
agent.save(checkpoint_path)