def trainAndCompare(self, K, noise): self.rs.deltaK = K for i in self.rs.sizeOfTarget: launchCMAESForAllPoint(self.rs, i, None, noise) resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/" resultName = "geneForHits/finalX/x.last" nameTheta = "Best" name = "geneForHits" nbret = 50 generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise) result1 = np.loadtxt(resultPath + "0.005/" + resultName) result2 = np.loadtxt(resultPath + "0.01/" + resultName) result3 = np.loadtxt(resultPath + "0.02/" + resultName) result4 = np.loadtxt(resultPath + "0.04/" + resultName) return -(cp.kl(result1, self.experiment1, 0.0025) + cp.kl(result2, self.experiment2, 0.005) + cp.kl(result3, self.experiment3, 0.01) + cp.kl(result4, self.experiment4, 0.02))
def trainAndCompare(self, K, noise): self.rs.deltaK = K for i in self.rs.sizeOfTarget: launchCMAESForAllPoint(self.rs, i, None, noise) resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/" resultName = "geneForHits/finalX/x.last" nameTheta = "Best" name = "geneForHits" nbret = 50 generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise) result1 = np.loadtxt(resultPath + "0.005/" + resultName) result2 = np.loadtxt(resultPath + "0.01/" + resultName) result3 = np.loadtxt(resultPath + "0.02/" + resultName) result4 = np.loadtxt(resultPath + "0.04/" + resultName) return -( cp.kl(result1, self.experiment1, 0.0025) + cp.kl(result2, self.experiment2, 0.005) + cp.kl(result3, self.experiment3, 0.01) + cp.kl(result4, self.experiment4, 0.02) )
def chooseFunction(choix, rs): if choix == 1: rorc = input("enter 1 if from Regression, anything if from previous CMAES: ") save = False rorc = int(rorc) if rorc == 1: save = True c = Chrono() launchCMAESForAllTargetSizesMulti(rs) c.stop() elif choix == 2: # TODO: Choose the kinematic model nameTheta = raw_input("Name of the controller file: ") name = raw_input("Folder where you want to save the results: ") nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) generateFromCMAES(nbret, rs, nameTheta, name) elif choix == 3: nameF = raw_input("Folder where the results are saved: ") plotVelocityProfile("OPTI", rs, nameF) elif choix == 4: nameF = raw_input("Folder where the results are saved: ") rorc = input("enter 1 if XY or 2 if Joint results: ") rorc = int(rorc) if rorc == 1: plotXYPositions("OPTI", rs, nameF, "All", False) else: plotArticularPositions("OPTI", rs, nameF) elif choix == 5: nameF = raw_input("Folder where the results are saved: ") tSize = raw_input("Target Size: ") plotMuscularActivations("OPTI", rs, nameF, tSize) elif choix == 6: nameF = raw_input("Folder where the results are saved: ") # tSize = raw_input('Target Size: ') # plotCostColorMap("OPTI",nameF,tSize) plotCostColorMap("OPTI", rs, nameF) elif choix == 7: nameF = raw_input("Folder where the results are saved: ") plotTimeDistanceTarget(nameF, rs) elif choix == 8: nameF = raw_input("Folder where the results are saved: ") plotPerfSizeDist(nameF, rs) elif choix == 9: nameF = raw_input("Folder where the results are saved: ") plotFittsLaw(nameF, rs) elif choix == 10: nameF = raw_input("Folder where the results are saved: ") plotTimeColorMap("OPTI", rs, nameF) elif choix == 11: rorc = input("enter 0 if Brent, 1 if Regression or 2 if CMAES results: ") rorc = int(rorc) if rorc == 0: trajectoriesAnimation("Brent", rs) elif rorc == 1: nameF = raw_input("Folder where the results are saved: ") trajectoriesAnimation("RBFN", rs, nameF) elif rorc == 2: nameF = raw_input("Folder where the results are saved: ") tSize = raw_input("Target Size: ") trajectoriesAnimation("OPTI", rs, nameF, tSize) elif choix == 12: nameF = raw_input("Folder where the results are saved: ") rorc = input("enter 1 if RBFN or 2 if CMAES results: ") # plotHitDispersion(nameF,"0.05") rorc = int(rorc) if rorc == 1: plotScattergram("RBFN", nameF, rs) elif rorc == 2: plotScattergram("OPTI", nameF, rs) elif choix == 13: rorc = input("enter 1 if from RBFN, anything if from previous CMAES: ") save = False rorc = int(rorc) if rorc == 1: save = True tSize = raw_input("Target Size: ") c = Chrono() launchCMAESForSpecificTargetSize(float(tSize), rs, save) c.stop() elif choix == 14: plotCMAESProgress(rs) elif choix == 15: name = raw_input("Name of the Regression controller file: ") fname = raw_input("Folder where you want to save the results: ") nbret = input("Number of repeat for each trajectory (int): ") c = Chrono() generateRichDataFromRegression(nbret, rs, name, fname) c.stop() elif choix == 16: nameTheta = raw_input("Name of the controller file: ") name = raw_input("Folder where you want to save the results: ") nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) c = Chrono() generateRichDataFromCMAES(nbret, rs, nameTheta, name) c.stop() elif choix == 17: plotTrajsInRepo() elif choix == 18: nameF = raw_input("Folder where the results are saved: ") plotXYEstimError("OPTI", rs, nameF, "All") elif choix == 19: nameF = raw_input("Folder where the results are saved: ") plotXYEstimErrorOfSpeed("OPTI", rs, nameF, "All") elif choix == 20: plotExperimentSetup(rs) elif choix == 21: plotManipulability(rs) elif choix == 22: plotManipulability2(rs) elif choix == 23: plotEstimatorPoint(rs, 0.04, 12) elif choix == 24: rorc = input("enter 1 if General CMAES, 2 if from scratch, anything if from previous CMAES point: ") save = False rorc = int(rorc) if rorc == 1: save = True elif rorc == 2: save = None tSize = raw_input("Target Size: ") c = Chrono() launchCMAESForAllPoint(rs, float(tSize), save) c.stop() elif choix == 25: # TODO: Test! rorc = input("enter 1 if General CMAES, 2 if from scratch, anything if from previous CMAES point: ") save = False rorc = int(rorc) if rorc == 1: save = True elif rorc == 2: save = None tSize = raw_input("Target Size: ") points = map(int, raw_input("Point(s): ").split()) print points lauchCMAESForListOfPoints(float(tSize), rs, save, points) elif choix == 26: size = raw_input("Target Size: ") while True: print (" Enter the number of the point you want sea, q for quit") point = raw_input("Point: ") if point == "q": break plotCMAESOnePointProgress(rs, size, point) elif choix == 27: # TODO: Choose the kinematic model nameTheta = raw_input("Name of the controller file: ") name = raw_input("Folder where you want to save the results: ") nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) generateFromCMAESNController(nbret, rs, nameTheta, name) elif choix == 28: nameF = raw_input("Folder where the results are saved: ") rorc = raw_input("Target Size: ") plotXYPositions("OPTI", rs, nameF, rorc, False) elif choix == 29: nameTheta = raw_input("Name of the controller file: ") name = raw_input("Folder where you want to save the results: ") nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) size = raw_input("Target Size: ") point = raw_input("Point: ") generateFromCMAESonePoint(nbret, rs, nameTheta, name, float(size), point) elif choix == 30: nameF = raw_input("Folder where the results are saved: ") # tSize = raw_input('Target Size: ') # plotCostColorMap("OPTI",nameF,tSize) plotCostColorMapFor12("OPTI", rs, nameF) elif choix == 31: size = raw_input("Target Size: ") checkAllPoint(rs, size) else: return 0 return 1
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Author: Corentin Arnaud Module: cluster Description: script to run the project on cluster ''' import sys from Utils.ReadXmlFile import ReadXmlFile from Main.MainCMAES import launchCMAESForAllPoint if __name__ == '__main__': rs = ReadXmlFile(sys.argv[1]) launchCMAESForAllPoint(rs, float(sys.argv[2]),True)
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Author: Corentin Arnaud Module: cluster Description: script to run the project on cluster ''' import sys from Utils.ReadXmlFile import ReadXmlFile from Main.MainCMAES import launchCMAESForAllPoint if __name__ == '__main__': rs = ReadXmlFile(sys.argv[1]) launchCMAESForAllPoint(rs, float(sys.argv[2]), True)
def chooseFunction(choix, rs): if choix == 1: rorc = input("enter 1 if from Regression, anything if from previous CMAES: ") save = False rorc = int(rorc) if rorc == 1: save = True c = Chrono() launchCMAESForAllTargetSizesMulti(rs) c.stop() elif choix == 2: #TODO: Choose the kinematic model nameTheta = raw_input('Name of the controller file: ') name = raw_input('Folder where you want to save the results: ') nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) generateFromCMAES(nbret, rs, nameTheta, name) elif choix == 3: nameF = raw_input('Folder where the results are saved: ') plotVelocityProfile("OPTI",rs,nameF) elif choix == 4: nameF = raw_input('Folder where the results are saved: ') rorc = input("enter 1 if XY or 2 if Joint results: ") rorc = int(rorc) if rorc == 1: plotXYPositions("OPTI",rs, nameF,"All",False) else: plotArticularPositions("OPTI",rs, nameF) elif choix == 5: nameF = raw_input('Folder where the results are saved: ') tSize = raw_input('Target Size: ') plotMuscularActivations("OPTI",rs,nameF,tSize) elif choix == 6: nameF = raw_input('Folder where the results are saved: ') #tSize = raw_input('Target Size: ') #plotCostColorMap("OPTI",nameF,tSize) plotCostColorMap("OPTI",rs, nameF) elif choix == 7: nameF = raw_input('Folder where the results are saved: ') plotTimeDistanceTarget(nameF, rs) elif choix == 8: nameF = raw_input('Folder where the results are saved: ') plotPerfSizeDist(nameF, rs) elif choix == 9: nameF = raw_input('Folder where the results are saved: ') plotFittsLaw(nameF, rs) elif choix == 10: nameF = raw_input('Folder where the results are saved: ') plotTimeColorMap("OPTI",rs, nameF) elif choix == 11: rorc = input("enter 0 if Brent, 1 if Regression or 2 if CMAES results: ") rorc = int(rorc) if rorc == 0: trajectoriesAnimation("Brent", rs) elif rorc == 1: nameF = raw_input('Folder where the results are saved: ') trajectoriesAnimation("RBFN",rs, nameF) elif rorc == 2: nameF = raw_input('Folder where the results are saved: ') tSize = raw_input('Target Size: ') trajectoriesAnimation("OPTI",rs, nameF, tSize) elif choix == 12: nameF = raw_input('Folder where the results are saved: ') rorc = input("enter 1 if RBFN or 2 if CMAES results: ") #plotHitDispersion(nameF,"0.05") rorc = int(rorc) if rorc == 1: plotScattergram("RBFN",nameF, rs) elif rorc == 2: plotScattergram("OPTI",nameF, rs) elif choix == 13: rorc = input("enter 1 if from RBFN, anything if from previous CMAES: ") save = False rorc = int(rorc) if rorc == 1: save = True tSize = raw_input('Target Size: ') c = Chrono() launchCMAESForSpecificTargetSize(float(tSize),rs,save) c.stop() elif choix == 14: plotCMAESProgress(rs) elif choix == 15: name = raw_input('Name of the Regression controller file: ') fname = raw_input('Folder where you want to save the results: ') nbret = input("Number of repeat for each trajectory (int): ") c = Chrono() generateRichDataFromRegression(nbret,rs, name, fname) c.stop() elif choix == 16: nameTheta = raw_input('Name of the controller file: ') name = raw_input('Folder where you want to save the results: ') nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) c = Chrono() generateRichDataFromCMAES(nbret,rs, nameTheta, name) c.stop() elif choix == 17: plotTrajsInRepo() elif choix == 18: nameF = raw_input('Folder where the results are saved: ') plotXYEstimError("OPTI",rs,nameF,"All") elif choix == 19: nameF = raw_input('Folder where the results are saved: ') plotXYEstimErrorOfSpeed("OPTI",rs,nameF,"All") elif choix == 20: plotExperimentSetup(rs) elif choix == 21: plotManipulability(rs) elif choix == 22: plotManipulability2(rs) elif choix == 23: plotEstimatorPoint(rs, 0.04, 12) elif choix == 24: rorc = input("enter 1 if General CMAES, 2 if from scratch, anything if from previous CMAES point: ") save = False rorc = int(rorc) if rorc == 1: save = True elif rorc==2: save=None tSize = raw_input('Target Size: ') c = Chrono() launchCMAESForAllPoint(rs,float(tSize),save) c.stop() elif choix == 25: #TODO: Test! rorc = input("enter 1 if General CMAES, 2 if from scratch, anything if from previous CMAES point: ") save = False rorc = int(rorc) if rorc == 1: save = True elif rorc==2: save=None tSize = raw_input('Target Size: ') points=map(int, raw_input('Point(s): ').split()) print points lauchCMAESForListOfPoints(float(tSize), rs, save, points) elif choix == 26: size=raw_input('Target Size: ') while True: print(" Enter the number of the point you want sea, q for quit") point=raw_input('Point: ') if(point=="q"): break plotCMAESOnePointProgress(rs,size, point) elif choix == 27: #TODO: Choose the kinematic model nameTheta = raw_input('Name of the controller file: ') name = raw_input('Folder where you want to save the results: ') nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) generateFromCMAESNController(nbret, rs, nameTheta, name) elif choix == 28: nameF = raw_input('Folder where the results are saved: ') rorc = raw_input("Target Size: ") plotXYPositions("OPTI",rs, nameF,rorc,False) elif choix == 29: nameTheta = raw_input('Name of the controller file: ') name = raw_input('Folder where you want to save the results: ') nbret = input("Number of repeat for each trajectory (int): ") nbret = int(nbret) size=raw_input('Target Size: ') point=raw_input('Point: ') generateFromCMAESonePoint(nbret, rs, nameTheta, name, float(size), point) elif choix == 30: nameF = raw_input('Folder where the results are saved: ') #tSize = raw_input('Target Size: ') #plotCostColorMap("OPTI",nameF,tSize) plotCostColorMapFor12("OPTI",rs, nameF) elif choix == 31: size=raw_input('Target Size: ') checkAllPoint(rs, size) else : return 0 return 1