forked from helenese/MDP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reward.py
42 lines (36 loc) · 910 Bytes
/
reward.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
import functions, numpy
def downtime(state):
if state[2]==0:
return(0)
else:
return(-1)
def production(state):
if state[2]==0:
return(0)
else:
loss=functions.prodloss(state)
return((-1)*loss)
def repair(state, strat):
if strat.decision(state)[5]==1:
return(-1)
else:
return(0)
def back(state, strat):
if strat.decision(state)[4]==1:
return(-1)
else:
return(0)
def out(state, strat):
if strat.decision(state)[3]==1:
return(-1)
else:
return(0)
def define_vector(states,rewardtype, strat):
val=[]
for state in states:
if rewardtype==downtime or rewardtype==production:
val.append(rewardtype(state))
else:
val.append(rewardtype(state, strat))
vector=numpy.array(val)
return(vector)