Esempio n. 1
0
def generateFromCMAESonePoint(repeat, rs, thetaFile, saveDir = 'Data', size=0.04, point=0):
    c = Chrono()
    thetaName = rs.OPTIpath + str(size)+"/"+str(point)+"/"+thetaFile
    saveName = rs.OPTIpath + str(size) + "/" + saveDir + "/"
    GenerateDataFromThetaOnePoint(rs,size, saveName,thetaName,repeat, point)
    c.stop()
    print("CMAES:End of generation")
Esempio n. 2
0
def generateFromCMAES(repeat, rs, thetaFile, saveDir = 'Data'):
    for el in rs.target_size:
        c = Chrono()
        thetaName = rs.OPTIpath + str(el) + "/" + thetaFile
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        GenerateDataFromTheta(rs,el,saveName,thetaName,repeat,True)
        c.stop()
    print("CMAES:End of generation")
Esempio n. 3
0
def generateFromDDPGNController(repeat, rs, thetaFile, saveDir="Data"):
    for el in rs.sizeOfTarget:
        c = Chrono()
        thetaName = rs.OPTIpath + str(el) + "/*/" + thetaFile
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        # GenerateDataFromThetaNController(rs,el, saveName,thetaName,repeat,True)
        c.stop()
    print("DDPG:End of generation")
Esempio n. 4
0
def generateFromCMAES(repeat, rs, thetaFile, saveDir='Data'):
    for el in rs.target_size:
        c = Chrono()
        thetaName = rs.OPTIpath + str(el) + "/" + thetaFile
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        GenerateDataFromTheta(rs, el, saveName, thetaName, repeat, True)
        c.stop()
    print("CMAES:End of generation")
Esempio n. 5
0
def generateFromDDPGNController(repeat, rs, thetaFile, saveDir='Data'):
    for el in rs.sizeOfTarget:
        c = Chrono()
        thetaName = rs.OPTIpath + str(el) + "/*/" + thetaFile
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        #GenerateDataFromThetaNController(rs,el, saveName,thetaName,repeat,True)
        c.stop()
    print("DDPG:End of generation")
Esempio n. 6
0
def generateFromCMAES(repeat, thetaFile, saveDir = 'Data'):
    rs = ReadSetupFile()
    for el in rs.sizeOfTarget:
        c = Chrono()
        thetaName = rs.CMAESpath + str(el) + "/" + thetaFile
        saveName = rs.CMAESpath + str(el) + "/" + saveDir + "/"
        GenerateDataFromTheta(rs,el,saveName,thetaName,repeat,True)
        c.stop()
    print("CMAES:End of generation")
Esempio n. 7
0
def generateFromCMAES(repeat, thetaFile, saveDir='Data'):
    rs = ReadSetupFile()
    for el in rs.sizeOfTarget:
        c = Chrono()
        thetaName = rs.CMAESpath + str(el) + "/" + thetaFile
        saveName = rs.CMAESpath + str(el) + "/" + saveDir + "/"
        GenerateDataFromTheta(rs, el, saveName, thetaName, repeat, True)
        c.stop()
    print("CMAES:End of generation")
Esempio n. 8
0
def GenerateRichDataFromTheta(rs, sizeOfTarget, foldername, thetaFile, repeat, save):
    exp = Experiments(rs, sizeOfTarget, save, foldername, thetaFile, rs.popsizeCmaes, rs.period)
    c = Chrono()
    cost = exp.runRichTrajectories(repeat)
    c.stop()
    print("Average cost: ", cost)
    print("foldername : ", foldername)
    if save:
        exp.saveCost()
Esempio n. 9
0
def GenerateRichDataFromTheta(rs, sizeOfTarget, foldername, thetaFile, repeat,
                              save):
    exp = Experiments(rs, sizeOfTarget, save, foldername, thetaFile,
                      rs.popsizeCmaes, rs.period)
    c = Chrono()
    cost = exp.runRichTrajectories(repeat)
    c.stop()
    print("Average cost: ", cost)
    print("foldername : ", foldername)
    if (save):
        exp.saveCost()
Esempio n. 10
0
def generateFromCMAESonePoint(repeat,
                              rs,
                              thetaFile,
                              saveDir='Data',
                              size=0.04,
                              point=0):
    c = Chrono()
    thetaName = rs.OPTIpath + str(size) + "/" + str(point) + "/" + thetaFile
    saveName = rs.OPTIpath + str(size) + "/" + saveDir + "/"
    GenerateDataFromThetaOnePoint(rs, size, saveName, thetaName, repeat, point)
    c.stop()
    print("CMAES:End of generation")
Esempio n. 11
0
def chooseFunction(choix, rs):
    if choix == 1:
        plotVelocityProfile("Brent", rs)
    elif choix == 2:
        plotArticularPositions("Brent", rs)
    elif choix == 3:
        plotXYPositions("Brent", rs)
    elif choix == 4:
        plotMuscularActivations("Brent", rs)


#------------------------------------------- RBFN
    elif choix == 5:
        c = Chrono()
        #        run(name,True)
        run(rs)
        c.stop()
    elif choix == 6:
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateFromRegression(nbret, rs, fname)
        c.stop()
    elif choix == 7:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("Regression", rs, nameF)
    elif choix == 8:
        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("Regression", rs, nameF, "All", True)  #False)#
        else:
            plotArticularPositions("Regression", rs, nameF)
    elif choix == 9:
        nameF = raw_input('Folder where the results are saved: ')
        plotMuscularActivations("Regression", rs, nameF)
    elif choix == 10:
        nameF = raw_input('Folder where the results are saved: ')
        plotCostColorMap("Regression", rs, nameF)
    elif choix == 11:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("Regression", rs, nameF, "All")
    elif choix == 12:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("Regression", rs, nameF, "All")
Esempio n. 12
0
def chooseFunction(choix, rs):
    if choix == 1:
        plotVelocityProfile("Brent",rs)
    elif choix == 2:
        plotArticularPositions("Brent",rs)
    elif choix == 3:
        plotXYPositions("Brent",rs)
    elif choix == 4:
        plotMuscularActivations("Brent",rs)

#------------------------------------------- RBFN
    elif choix == 5:
        c = Chrono()
#        run(name,True)
        run(rs)
        c.stop()
    elif choix == 6:
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateFromRegression(nbret, rs, fname)
        c.stop()
    elif choix == 7:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("Regression",rs, nameF)
    elif choix == 8:
        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("Regression", rs, nameF,"All",True)#False)#
        else:
            plotArticularPositions("Regression",rs, nameF)
    elif choix == 9:
        nameF = raw_input('Folder where the results are saved: ')
        plotMuscularActivations("Regression",rs, nameF)
    elif choix == 10:
        nameF = raw_input('Folder where the results are saved: ')
        plotCostColorMap("Regression", rs, nameF)
    elif choix == 11:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("Regression", rs, nameF,"All")
    elif choix == 12:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("Regression", rs, nameF,"All")
Esempio n. 13
0
def generateFromDDPG(repeat, rs, thetaFile, saveDir='Data'):
    for el in rs.sizeOfTarget:
        c = Chrono()
        actor = simple_actor_network(rs.inputDim,
                                     rs.outputDim,
                                     l1_size=rs.hiddenLayers[0][1],
                                     l2_size=rs.hiddenLayers[1][1],
                                     learning_rate=rs.learningRate)
        env = DDPGEnv(rs, el, rs.thetaFile, actor=actor, saveDir=saveDir)
        thetaName = rs.OPTIpath + str(el) + "/" + thetaFile + ".theta"
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        os.system("rm " + saveName + "Log/*.log 2>/dev/null")
        parameters = np.loadtxt(thetaName)
        actor.load_parameters(parameters)
        cost, time = env.saveAllTraj(repeat)
        c.stop()
        print("Average cost: ", cost)
        print("Average time: ", time)
        print("foldername : ", saveName)
    print("DDPG:End of generation")
Esempio n. 14
0
def generateFromDDPG(repeat, rs, thetaFile, saveDir="Data"):
    for el in rs.sizeOfTarget:
        c = Chrono()
        actor = simple_actor_network(
            rs.inputDim,
            rs.outputDim,
            l1_size=rs.hiddenLayers[0][1],
            l2_size=rs.hiddenLayers[1][1],
            learning_rate=rs.learningRate,
        )
        env = DDPGEnv(rs, el, rs.thetaFile, actor=actor, saveDir=saveDir)
        thetaName = rs.OPTIpath + str(el) + "/" + thetaFile + ".theta"
        saveName = rs.OPTIpath + str(el) + "/" + saveDir + "/"
        os.system("rm " + saveName + "Log/*.log 2>/dev/null")
        parameters = np.loadtxt(thetaName)
        actor.load_parameters(parameters)
        cost, time = env.saveAllTraj(repeat)
        c.stop()
        print("Average cost: ", cost)
        print("Average time: ", time)
        print("foldername : ", saveName)
    print("DDPG:End of generation")
Esempio n. 15
0
def testRBFNs():
    for i in range(3):
        c = Chrono()
        generateFromRegression(3, "R" + str(i), "SR" + str(i))
        c.stop()
Esempio n. 16
0

from Main.MainCMAES import generateFromRegression
from Regression.RunRegression import run
from Plot.plotFunctions import plotXYPositions
from Main.Test import *
from Utils.Chrono import Chrono
from Utils.ReadXmlFile import ReadXmlFile

setupFile="setupRBFN.xml"
thetaName="ScriptRBFNxml"
folder="TrajRBFNxml"

rs=ReadXmlFile(setupFile)
c = Chrono()
run(rs)
c.stop()
generateFromRegression(1, rs, thetaName, folder)
plotXYPositions("Regression",rs, folder,"All",True)
testRegression(rs, thetaName, folder)
def run():
    c = Chrono()
    generateFromRBFN(2, "Full4", "Test")
    c.stop()
    def runTrajectoriesCMAES(self, theta):
        '''
    	Generates all the trajectories of the experimental setup and return the mean cost. This function is used by cmaes to optimize the controller.
    
    	Input:		-theta: vector of parameters, one dimension normalized numpy array
    
    	Ouput:		-meanAll: the mean of the cost of all trajectories generated, float
    	'''
        if (self.call==0):
            self.localBestCost = -1000000.0
            self.localWorstCost = 1000000.0
            self.localBestTime = -1000000.0
            self.localWorstTime = 1000000.0
            self.periodMeanCost = 0.0
            self.periodMeanTime = 0.0
        c = Chrono()
        self.initTheta(theta)
        #print "theta avant appel :", theta
        #compute all the trajectories x times each, x = numberOfRepeat
        meanCost, meanTime = self.runTrajectoriesForResultsGeneration(self.numberOfRepeat)
        #cma.plot()
        #opt = cma.CMAOptions()
        #print "CMAES options :", opt
        c.stop()

        print("Indiv #: ", self.call, "\n Cost: ", meanCost)

        if meanCost>self.localBestCost:
            self.localBestCost = meanCost

        if meanTime>self.localBestTime:
            self.localBestTime = meanTime

        if meanCost<self.localWorstCost:
            self.localWorstCost = meanCost

        if meanTime<self.localWorstTime:
            self.localWorstTime = meanTime

        if meanCost>self.bestCost:
            self.bestCost = meanCost
            if meanCost>0:
                extension = ".save" + str(meanCost)
                filename = findDataFilename(self.foldername+"Theta/", "theta", extension)
                np.savetxt(filename, self.theta)
        
        self.periodMeanCost += meanCost
        self.periodMeanTime += meanTime

        self.call += 1
        self.call = self.call%self.period

        if (self.call==0):
            self.periodMeanCost = self.periodMeanCost/self.period
            self.periodMeanTime = self.periodMeanTime/self.period
            self.CMAESCostStore.append((self.localWorstCost,self.periodMeanCost,self.localBestCost))
            self.CMAESTimeStore.append((self.localWorstTime,self.periodMeanTime,self.localBestTime))
            costfoldername = self.foldername+"Cost/"
            checkIfFolderExists(costfoldername)
            np.savetxt(costfoldername+"cmaesCost.log",self.CMAESCostStore) #Note: inefficient, should rather add to the file
            np.savetxt(costfoldername+"cmaesTime.log",self.CMAESTimeStore) #Note: inefficient, should rather add to the file

        return 10.0*(self.rs.rhoCF-meanCost)/self.rs.rhoCF
Esempio n. 19
0
def chooseFunction(choix):
    if choix == 1:
        plotVelocityProfile("Brent")
    elif choix == 2:
        plotArticularPositions("Brent")
    elif choix == 3:
        plotXYPositions("Brent")
    elif choix == 4:
        plotMuscularActivations("Brent")

#------------------------------------------- RBFN
    elif choix == 5:
        name = raw_input('Name of file to save the RBFN controller: ')
        c = Chrono()
#        runRBFN(name,True)
        runRBFN(name,False)
        c.stop()
    elif choix == 6:
        name = raw_input('Name of the RBFN controller file: ')
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateFromRBFN(nbret, name, fname)
        c.stop()
    elif choix == 7:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("RBFN",nameF)
    elif choix == 8:
        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("RBFN",nameF,"All",True)#False)#
        else:
            plotArticularPositions("RBFN",nameF)
    elif choix == 9:
        nameF = raw_input('Folder where the results are saved: ')
        plotMuscularActivations("RBFN",nameF)
    elif choix == 10:
        nameF = raw_input('Folder where the results are saved: ')
        plotCostColorMap("RBFN",nameF)
    elif choix == 28:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("RBFN",nameF,"All")
    elif choix == 29:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("RBFN",nameF,"All")

#------------------------------------------- CMAES
    elif choix == 11:
        rorc = input("enter 1 if from RBFN, anything if from previous CMAES: ")
        save = False
        rorc = int(rorc)
        if rorc == 1:
            save = True
        name = raw_input('Name of the controller file: ')
        c = Chrono()
        launchCMAESForAllTargetSizes(name,save)
        c.stop()
    elif choix == 12:
        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, nameTheta, name)
    elif choix == 13:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("CMAES",nameF)
    elif choix == 14:
        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("CMAES",nameF,"All",False)
        else:
            tSize = raw_input('Target Size: ')
            plotArticularPositions("CMAES",nameF,tSize)
    elif choix == 15:
        nameF = raw_input('Folder where the results are saved: ')
        tSize = raw_input('Target Size: ')
        plotMuscularActivations("CMAES",nameF,tSize)
    elif choix == 16:
        nameF = raw_input('Folder where the results are saved: ')
        #tSize = raw_input('Target Size: ')
        #plotCostColorMap("CMAES",nameF,tSize)
        plotCostColorMap("CMAES",nameF)
    elif choix == 17:
        nameF = raw_input('Folder where the results are saved: ')
        plotTimeDistanceTarget(nameF)
    elif choix == 18:
        nameF = raw_input('Folder where the results are saved: ')
        plotPerfSizeDist(nameF)
    elif choix == 19:
        nameF = raw_input('Folder where the results are saved: ')
        plotFittsLaw(nameF)
    elif choix == 20:
        nameF = raw_input('Folder where the results are saved: ')
        plotTimeColorMap("CMAES",nameF)
    elif choix == 21:
        rorc = input("enter 0 if Brent, 1 if RBFN or 2 if CMAES results: ")
        rorc = int(rorc)
        if rorc == 0:
            trajectoriesAnimation("Brent")
        elif rorc == 1:
            nameF = raw_input('Folder where the results are saved: ')
            trajectoriesAnimation("RBFN",nameF)
        elif rorc == 2:
            nameF = raw_input('Folder where the results are saved: ')
            tSize = raw_input('Target Size: ')
            trajectoriesAnimation("CMAES",nameF, tSize)
    elif choix == 22:
        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)
        elif rorc == 2:
            plotScattergram("CMAES",nameF)
    elif choix == 23:
        name = raw_input('Name of the controller file: ')
        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),name,save)
        c.stop()
    elif choix == 24:
        plotCMAESProgress()
    elif choix == 25:
        name = raw_input('Name of the RBFN controller file: ')
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateRichDataFromRBFN(nbret, name, fname)
        c.stop()
    elif choix == 26:
        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, nameTheta, name)
        c.stop()
    elif choix == 27:
        plotTrajsInRepo()
    elif choix == 30:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("CMAES",nameF,"All")
    elif choix == 31:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("CMAES",nameF,"All")
    elif choix == 32:
        plotExperimentSetup()
    elif choix == 33:
        plotManipulability()
    elif choix == 34:
        plotManipulability2()
Esempio n. 20
0
def testRBFNs():
     for i in range(3):
        c = Chrono()
        generateFromRBFN(3, "R"+str(i), "SR"+str(i))
        c.stop()
Esempio n. 21
0
def generateRBFNs():
     for i in range(20):
        c = Chrono()
        runRBFN("X"+str(i),True)
        c.stop()
Esempio n. 22
0
def chooseFunction(choix, rs):
    if choix == 1:
        c = Chrono()
        #TODO: DDPGForAllTargetSizes
        #launchDDPGForAllTargetSizesMulti(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)
        generateFromDDPG(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 DDPG 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 DDPG 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:
        tSize = raw_input('Target Size: ')
        c = Chrono()
        launchDDPGForSpecificTargetSize(float(tSize),rs)
        c.stop()
    elif choix == 14:
        plotDDPGProgress(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()
        generateRichDataFromDDPG(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:
        plotEstimator(rs, 0.04, 0., 0.25)
    elif choix == 24:
        tSize = raw_input('Target Size: ')
        c = Chrono()
        launchDDPGForAllPoint(rs,float(tSize))
        #launchDDPGForSpecificTargetSizeAndSpeceficBeginning(float(tSize), rs, [0, [0, 0.2]])
        c.stop()
    elif choix == 25:
        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
            plotDDPGOnePointProgress(rs,size, point)
    elif choix == 26:
        #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)
        generateFromDDPGNController(nbret, rs, nameTheta, name)
    elif choix == 27:
        nameF = raw_input('Folder where the results are saved: ')
        rorc = raw_input("Target Size: ")
        plotXYPositions("OPTI",rs, nameF,rorc,False)
    else :
        return 0
    return 1
Esempio n. 23
0
def generateNNs():
    for i in range(20):
        c = Chrono()
        runNN("X" + str(i), True)
        c.stop()
Esempio n. 24
0
#exp2.tm.stateEstimator.initStore(state)
exp3.tm.stateEstimator.initStore(state)

nbE=0
error=np.zeros(4)
c=Chrono()
for i in range(state.shape[0]):
    if(state[i][0]==0 and state[i][1]==0):
        exp.tm.stateEstimator.initStore(state[i])
        tmp=0
    inferredState = exp.tm.stateEstimator.getEstimState(state[i], command[i][:6])
    if i<state.shape[0]-1 and not (state[i+1][0]==0 and state[i+1][1]==0):
        error += (inferredState - state[i+1])**2
        nbE+=1
    tmp+=1
c.stop()
print (np.mean(error/nbE))

'''
nbE=0
error=np.zeros(4)
c=Chrono()
for i in range(1000):
    if(state[i][0]==state[i][1]):
        exp2.tm.stateEstimator.initStore(state[i])
        tmp=0
    inferredState = exp2.tm.stateEstimator.getEstimState(state[i], command[i][:6])
    
    if tmp >10:
        error += (inferredState - nextState[i-10])**2
        nbE+=1
Esempio n. 25
0
def run():
    c = Chrono()
    generateFromNN(1, "Random", "R1")
    c.stop()
Esempio n. 26
0
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
Esempio n. 27
0
def run():
    c = Chrono()
    generateFromRBFN(2, "Full", "Test")
    c.stop()
Esempio n. 28
0
def chooseFunction(choix):
    if choix == 1:
        plotVelocityProfile("Brent")
    elif choix == 2:
        plotArticularPositions("Brent")
    elif choix == 3:
        plotXYPositions("Brent")
    elif choix == 4:
        plotMuscularActivations("Brent")

#------------------------------------------- NN
    elif choix == 5:
        name = raw_input('Name of file to save the NN controller: ')
        c = Chrono()
        #runNN(name)
        createNN(name)
        c.stop()
    elif choix == 6:
        name = raw_input('Name of the NN controller file: ')
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateFromNN(nbret, name, fname)
        c.stop()
    elif choix == 7:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("NN", nameF)
    elif choix == 8:
        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("NN", nameF, "All", True)  #False)#
        else:
            plotArticularPositions("NN", nameF)
    elif choix == 9:
        nameF = raw_input('Folder where the results are saved: ')
        plotMuscularActivations("NN", nameF)
    elif choix == 10:
        nameF = raw_input('Folder where the results are saved: ')
        plotCostColorMap("NN", nameF)
    elif choix == 28:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("NN", nameF, "All")
    elif choix == 29:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("NN", nameF, "All")


#------------------------------------------- CMAES
    elif choix == 11:
        rorc = input("enter 1 if from NN, anything if from previous CMAES: ")
        save = False
        rorc = int(rorc)
        if rorc == 1:
            save = True
        name = raw_input('Name of the controller file: ')
        c = Chrono()
        launchCMAESForAllTargetSizes(name, save)
        c.stop()
    elif choix == 12:
        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, nameTheta, name)
    elif choix == 13:
        nameF = raw_input('Folder where the results are saved: ')
        plotVelocityProfile("CMAES", nameF)
    elif choix == 14:
        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("CMAES", nameF, "All", False)
        else:
            tSize = raw_input('Target Size: ')
            plotArticularPositions("CMAES", nameF, tSize)
    elif choix == 15:
        nameF = raw_input('Folder where the results are saved: ')
        tSize = raw_input('Target Size: ')
        plotMuscularActivations("CMAES", nameF, tSize)
    elif choix == 16:
        nameF = raw_input('Folder where the results are saved: ')
        #tSize = raw_input('Target Size: ')
        #plotCostColorMap("CMAES",nameF,tSize)
        plotCostColorMap("CMAES", nameF)
    elif choix == 17:
        nameF = raw_input('Folder where the results are saved: ')
        plotTimeDistanceTarget(nameF)
    elif choix == 18:
        nameF = raw_input('Folder where the results are saved: ')
        plotPerfSizeDist(nameF)
    elif choix == 19:
        nameF = raw_input('Folder where the results are saved: ')
        plotFittsLaw(nameF)
    elif choix == 20:
        nameF = raw_input('Folder where the results are saved: ')
        plotTimeColorMap("CMAES", nameF)
    elif choix == 21:
        rorc = input("enter 0 if Brent, 1 if NN or 2 if CMAES results: ")
        rorc = int(rorc)
        if rorc == 0:
            trajectoriesAnimation("Brent")
        elif rorc == 1:
            nameF = raw_input('Folder where the results are saved: ')
            trajectoriesAnimation("NN", nameF)
        elif rorc == 2:
            nameF = raw_input('Folder where the results are saved: ')
            tSize = raw_input('Target Size: ')
            trajectoriesAnimation("CMAES", nameF, tSize)
    elif choix == 22:
        nameF = raw_input('Folder where the results are saved: ')
        rorc = input("enter 1 if NN or 2 if CMAES results: ")
        #plotHitDispersion(nameF,"0.05")
        rorc = int(rorc)
        if rorc == 1:
            plotScattergram("NN", nameF)
        elif rorc == 2:
            plotScattergram("CMAES", nameF)
    elif choix == 23:
        name = raw_input('Name of the controller file: ')
        rorc = input("enter 1 if from NN, 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), name, save)
        c.stop()
    elif choix == 24:
        plotCMAESProgress()
    elif choix == 25:
        name = raw_input('Name of the NN controller file: ')
        fname = raw_input('Folder where you want to save the results: ')
        nbret = input("Number of repeat for each trajectory (int): ")
        c = Chrono()
        generateRichDataFromNN(nbret, name, fname)
        c.stop()
    elif choix == 26:
        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, nameTheta, name)
        c.stop()
    elif choix == 27:
        plotTrajsInRepo()
    elif choix == 30:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimError("CMAES", nameF, "All")
    elif choix == 31:
        nameF = raw_input('Folder where the results are saved: ')
        plotXYEstimErrorOfSpeed("CMAES", nameF, "All")
    elif choix == 32:
        plotExperimentSetup()
    elif choix == 33:
        plotManipulability()
    elif choix == 34:
        plotManipulability2()
Esempio n. 29
0
    def runTrajectoriesCMAES(self, theta):
        '''
    	Generates all the trajectories of the experimental setup and return the mean cost. This function is used by cmaes to optimize the controller.
    
    	Input:		-theta: vector of parameters, one dimension normalized numpy array
    
    	Ouput:		-meanAll: the mean of the cost of all trajectories generated, float
    	'''
        if (self.call == 0):
            self.localBestCost = -1000000.0
            self.localWorstCost = 1000000.0
            self.localBestTime = -1000000.0
            self.localWorstTime = 1000000.0
            self.periodMeanCost = 0.0
            self.periodMeanTime = 0.0
        c = Chrono()
        self.initTheta(theta)
        #print "theta avant appel :", theta
        #compute all the trajectories x times each, x = numberOfRepeat
        meanCost, meanTime = self.runTrajectoriesForResultsGeneration(
            self.numberOfRepeat)
        #cma.plot()
        #opt = cma.CMAOptions()
        #print "CMAES options :", opt
        c.stop()

        print("Indiv #: ", self.call, "\n Cost: ", meanCost)

        if meanCost > self.localBestCost:
            self.localBestCost = meanCost

        if meanTime > self.localBestTime:
            self.localBestTime = meanTime

        if meanCost < self.localWorstCost:
            self.localWorstCost = meanCost

        if meanTime < self.localWorstTime:
            self.localWorstTime = meanTime

        if meanCost > self.bestCost:
            self.bestCost = meanCost
            if meanCost > 0:
                extension = ".save" + str(meanCost)
                filename = findDataFilename(self.foldername + "Theta/",
                                            "theta", extension)
                np.savetxt(filename, self.theta)

        self.periodMeanCost += meanCost
        self.periodMeanTime += meanTime

        self.call += 1
        self.call = self.call % self.period

        if (self.call == 0):
            self.periodMeanCost = self.periodMeanCost / self.period
            self.periodMeanTime = self.periodMeanTime / self.period
            self.CMAESCostStore.append(
                (self.localWorstCost, self.periodMeanCost, self.localBestCost))
            self.CMAESTimeStore.append(
                (self.localWorstTime, self.periodMeanTime, self.localBestTime))
            costfoldername = self.foldername + "Cost/"
            checkIfFolderExists(costfoldername)
            np.savetxt(costfoldername + "cmaesCost.log", self.CMAESCostStore
                       )  #Note: inefficient, should rather add to the file
            np.savetxt(costfoldername + "cmaesTime.log", self.CMAESTimeStore
                       )  #Note: inefficient, should rather add to the file

        return 10.0 * (self.rs.rhoCF - meanCost) / self.rs.rhoCF
Esempio n. 30
0
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
Esempio n. 31
0
def testNNs():
    for i in range(3):
        c = Chrono()
        generateFromNN(3, "R" + str(i), "SR" + str(i))
        c.stop()
Esempio n. 32
0
def run():
    c = Chrono()
    generateFromNN(1, "Random", "R1")
    c.stop()
Esempio n. 33
0
from Main.MainCMAES import generateFromRegression
from Regression.RunRegression import run
from Plot.plotFunctions import plotXYPositions
from Main.Test import *
from Utils.Chrono import Chrono
from Utils.ReadXmlFile import ReadXmlFile

setupFile = "setupRBFN.xml"
thetaName = "ScriptRBFNxml"
folder = "TrajRBFNxml"

rs = ReadXmlFile(setupFile)
c = Chrono()
run(rs)
c.stop()
generateFromRegression(1, rs, thetaName, folder)
plotXYPositions("Regression", rs, folder, "All", True)
testRegression(rs, thetaName, folder)
Esempio n. 34
0
def chooseFunction(choix, rs):
    if choix == 1:
        c = Chrono()
        #TODO: DDPGForAllTargetSizes
        #launchDDPGForAllTargetSizesMulti(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)
        generateFromDDPG(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 DDPG 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 DDPG 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:
        tSize = raw_input('Target Size: ')
        c = Chrono()
        launchDDPGForSpecificTargetSize(float(tSize), rs)
        c.stop()
    elif choix == 14:
        plotDDPGProgress(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()
        generateRichDataFromDDPG(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:
        plotEstimator(rs, 0.04, 0., 0.25)
    elif choix == 24:
        tSize = raw_input('Target Size: ')
        c = Chrono()
        launchDDPGForAllPoint(rs, float(tSize))
        #launchDDPGForSpecificTargetSizeAndSpeceficBeginning(float(tSize), rs, [0, [0, 0.2]])
        c.stop()
    elif choix == 25:
        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
            plotDDPGOnePointProgress(rs, size, point)
    elif choix == 26:
        #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)
        generateFromDDPGNController(nbret, rs, nameTheta, name)
    elif choix == 27:
        nameF = raw_input('Folder where the results are saved: ')
        rorc = raw_input("Target Size: ")
        plotXYPositions("OPTI", rs, nameF, rorc, False)
    else:
        return 0
    return 1