@@ -98,7 +98,7 @@ public List<String> search(Problem p) throws Exception {
9898 // next <- a randomly selected successor of current
9999 next = Util .selectRandomlyFromList (children );
100100 // /\E <- VALUE[next] - VALUE[current]
101- int deltaE = getValue (p , next ) - getValue (p , current );
101+ double deltaE = getValue (p , next ) - getValue (p , current );
102102
103103 if (shouldAccept (temperature , deltaE )) {
104104 current = next ;
@@ -111,13 +111,13 @@ public List<String> search(Problem p) throws Exception {
111111
112112 // if /\E > 0 then current <- next
113113 // else current <- next only with probablity e^(/\E/T)
114- private boolean shouldAccept (double temperature , int deltaE ) {
114+ private boolean shouldAccept (double temperature , double deltaE ) {
115115 return (deltaE > 0.0 )
116116 || (new Random ().nextDouble () <= probabilityOfAcceptance (
117117 temperature , deltaE ));
118118 }
119119
120- public double probabilityOfAcceptance (double temperature , int deltaE ) {
120+ public double probabilityOfAcceptance (double temperature , double deltaE ) {
121121 return Math .exp (deltaE / temperature );
122122 }
123123
@@ -129,13 +129,13 @@ public Object getLastSearchState() {
129129 return lastState ;
130130 }
131131
132- private int getValue (Problem p , Node n ) {
132+ private double getValue (Problem p , Node n ) {
133133 return -1 * getHeuristic (p , n ); // assumption greater heuristic value =>
134134 // HIGHER on hill; 0 == goal state;
135135 // SA deals with gardient DESCENT
136136 }
137137
138- private int getHeuristic (Problem p , Node aNode ) {
138+ private double getHeuristic (Problem p , Node aNode ) {
139139 return p .getHeuristicFunction ().getHeuristicValue (aNode .getState ());
140140 }
141141}
0 commit comments