RLPark 1.0.0
Reinforcement Learning Framework in Java

FrozenParameters.java

Go to the documentation of this file.
00001 package rlpark.plugin.rltoys.experiments.parametersweep.parameters;
00002 
00003 import java.util.ArrayList;
00004 import java.util.Collections;
00005 import java.util.List;
00006 import java.util.Map;
00007 
00008 public class FrozenParameters extends AbstractParameters {
00009   private static final long serialVersionUID = -1853925775244660996L;
00010   protected final int hashcode;
00011 
00012   public FrozenParameters(RunInfo infos, Map<String, Double> parameters, Map<String, Double> results) {
00013     super(infos);
00014     putAllSorted(parameters, this.parameters);
00015     putAllSorted(results, this.results);
00016     hashcode = computeHashcode(parameters);
00017   }
00018 
00019   private void putAllSorted(Map<String, Double> source, Map<String, Double> target) {
00020     List<String> sortedKeys = new ArrayList<String>(source.keySet());
00021     Collections.sort(sortedKeys);
00022     for (String key : sortedKeys)
00023       target.put(key, source.get(key));
00024   }
00025 
00026   static protected int computeHashcode(Map<String, Double> parameters) {
00027     int hashcode = 0;
00028     for (Map.Entry<String, Double> entry : parameters.entrySet())
00029       hashcode += entry.hashCode();
00030     return hashcode;
00031   }
00032 
00033   @Override
00034   public boolean equals(Object obj) {
00035     if (obj == null)
00036       return false;
00037     if (super.equals(obj))
00038       return true;
00039     AbstractParameters other = (AbstractParameters) obj;
00040     return parameters.equals(other.parameters) && infos().equals(other.infos());
00041   }
00042 
00043   @Override
00044   public int hashCode() {
00045     return hashcode;
00046   }
00047 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark