public void addMembers(OrderedSolutionList a_list) { int nMembers = a_list.size(); for (int i = 0; i < nMembers; ++i) { Solution member = a_list.get(i); this.add(member); } }
public void addMembers(OrderedSolutionList a_list) { int nMembers = a_list.size(); for (int i = 0; i < nMembers; ++i) { Solution member = a_list.get(i); this.add(member); } }
public int bestActionIndex(double[] targets) { bool verbose = false; int selected = -1; double[][] bounds = m_player.getValueBounds(); double bestValue = -Double.MaxValue; OrderedSolutionList myPA = pa.m_members; int numMembers = myPA.size(); if (verbose && numMembers > 1) { Console.WriteLine("Choosing among " + myPA.size() + " members."); } for (int i = 0; i < numMembers; ++i) { double[] thisRes = myPA.get(i).m_data; /* * double val0 = Utils.normalise(thisRes[0], bounds[0][0], bounds[0][1]); * double val1 = Utils.normalise(thisRes[1], bounds[1][0], bounds[1][1]); * double val2 = Utils.normalise(thisRes[2], bounds[2][0], bounds[2][1]); * double val = targets[0] * val0 + targets[1] * val1 + targets[2] * val2;*/ double val = 0.0; for (int t = 0; t < targets.Length; ++t) { double v = Utils.normalise(thisRes[t], bounds[t][0], bounds[t][1]); val += v * targets[t]; } if (verbose && numMembers > 1) { if (thisRes.Length == 3) { Console.WriteLine(" [%.4f, %.4f, %.4f] => %.4f, from %d\n", thisRes[0], thisRes[1], thisRes[2], val, myPA.get(i).m_through); } if (thisRes.Length == 2) { Console.WriteLine(" [%.4f, %.4f] => %.4f, from %d\n", thisRes[0], thisRes[1], val, myPA.get(i).m_through); } } //Console.WriteLine("Element in PA " + i + ": " + val); if (val > bestValue) { bestValue = val; selected = i; } } if (verbose && numMembers > 1) { Console.WriteLine(" Selected: " + selected); } if (selected == -1) { //Console.WriteLine(" ********************* SELECTED -1, myPA.Count(): " + myPA.Count() + " ***************"); return(0); } double[] selectedTarget = myPA.get(selected).m_data; //List<int> navSet = valueRoute.Keys.ToList(); foreach (int key in valueRoute.Keys) { List <Solution> resFromThisChild = valueRoute[key]; for (int i = 0; i < resFromThisChild.Count; ++i) { double[] sol = resFromThisChild[i].m_data; //Console.WriteLine("PA point " + key + ":" + i + ": " + sol[0] + ", " + sol[1] + ", nVis: " + children[key].nVisits); if (sol.Length == 3 && sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1] && sol[2] == selectedTarget[2]) //if(sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1]) { //Console.WriteLine("SELECTED-3: " + children[key].nVisits + "," + sol[0] + "," + sol[1] + ": " + key); return(key); } else if (sol.Length == 2 && sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1]) { //Console.WriteLine("SELECTED-2: " + children[key].nVisits + "," + sol[0] + "," + sol[1] + ": " + key); return(key); } } } //If we get down here, we've done something wrong. /* pa.printArchive(); * * Console.WriteLine("Looking for: " + selectedTarget[0] + "," + selectedTarget[1]); * for(Integer key : navSet) * { * LinkedList<double[]> resFromThisChild = valueRoute.get(key); * * for(int i =0; i < resFromThisChild.Count(); ++i) * { * double[] sol = resFromThisChild.get(i); * Console.WriteLine(key + ": " + sol[0] + "," + sol[1]); * if(sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1]) * Console.WriteLine("FOUND!"); * } * } */ //throw new Exception("Unexpected selection: " + selected); return(selected); }
public ParetoArchive() { m_hvClean = false; m_hv = -1; m_members = new OrderedSolutionList(); }
public ParetoArchive() { m_hvClean = false; m_hv = -1; m_members = new OrderedSolutionList(); }
public int bestActionIndexEuqDistance(double[] targets) { bool verbose = false; int selected = -1; double[][] bounds = m_player.getValueBounds(); double distance = Double.MaxValue; OrderedSolutionList myPA = pa.m_members; int numMembers = myPA.size(); if (verbose && numMembers > 1) { Console.WriteLine("Choosing among " + myPA.size() + " members."); } for (int i = 0; i < numMembers; ++i) { double[] thisRes = myPA.get(i).m_data; double[] val = new double[targets.Length]; for (int t = 0; t < targets.Length; ++t) { double v = Utils.normalise(thisRes[t], bounds[t][0], bounds[t][1]); val[t] = v; } double thisDist = Utils.distanceEuq(val, targets); if (thisDist < distance) { distance = thisDist; selected = i; } } if (verbose && numMembers > 1) { Console.WriteLine(" Selected: " + selected); } double[] selectedTarget = myPA.get(selected).m_data; //List<int> navSet = valueRoute.Keys.ToList(); foreach (int key in valueRoute.Keys) { List <Solution> resFromThisChild = valueRoute[key]; for (int i = 0; i < resFromThisChild.Count; ++i) { double[] sol = resFromThisChild[i].m_data; if (sol.Length == 3 && sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1] && sol[2] == selectedTarget[2]) { return(key); } else if (sol.Length == 2 && sol[0] == selectedTarget[0] && sol[1] == selectedTarget[1]) { return(key); } } } //throw new Exception("Unexpected selection: " + selected); return(selected); }