-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.java
More file actions
97 lines (76 loc) · 1.88 KB
/
State.java
File metadata and controls
97 lines (76 loc) · 1.88 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package template;
import com.sun.istack.internal.NotNull;
import logist.topology.Topology.City;
import java.util.Random;
/**
* reactive Created by samsara on 09/10/2015.
*/
public class State
{
private City from;
private City to;
private City bestAction;
private double bestReward;
private double pre_bestReward;
public State(City from, City to)
{
this.from = from;
this.to = to;
Random random = new Random();
this.bestAction = from.randomNeighbor(random);
this.bestReward = - Double.MAX_VALUE;
this.pre_bestReward = - Double.MAX_VALUE;
}
@NotNull public City getBestAction()
{
return bestAction;
}
public City getFrom()
{
return from;
}
public City getTo()
{
return to;
}
public double getPre_bestReward()
{
return pre_bestReward;
}
@NotNull public double getBestReward()
{
return bestReward;
}
public void updateBestReward(double newBest, City newBestAction)
{
pre_bestReward = bestReward;
bestReward = newBest;
bestAction = newBestAction;
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
State state = (State) o;
return to.equals(state.to) && from.equals(state.from);
}
@Override
public int hashCode()
{
int result = from.hashCode();
result = 31 * result + to.hashCode();
return result;
}
@Override
public String toString()
{
return "State{" +
"from=" + from +
", to=" + to +
", bestAction=" + bestAction +
", bestReward=" + bestReward +
", pre_bestReward=" + pre_bestReward +
'}';
}
}