Example #1
0
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)
        self.evo_strat=ec.SA(self.rand)
        self.evo_strat.terminator=terminators.evaluation_termination
        if option_obj.output_level=="1":
            self.evo_strat.observer=[observers.population_observer,observers.file_observer]
        else:
            self.evo_strat.observer=[observers.file_observer]
        self.max_evaluation=option_obj.max_evaluation
        self.mutation_rate=option_obj.mutation_rate
        self.g_m=option_obj.m_gauss
        self.g_std=option_obj.std_gauss
        self.inint_T=option_obj.init_temp
        self.cooling_rate=option_obj.cooling_rate

        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        self.maximize=False #hard wired, always minimize
        self.stat_file=open("stat_file.txt","w")
        self.ind_file=open("ind_file.txt","w")
        #inspyred needs sequence of seeds
        #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
        try:
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=Random()
     self.seed=option_obj.seed
     self.rand.seed(self.seed)
     self.evo_strat=ec.SA(self.rand)
     self.evo_strat.terminator=terminators.evaluation_termination
     if option_obj.output_level=="1":
         self.evo_strat.observer=[observers.population_observer,observers.file_observer]
     else:
         self.evo_strat.observer=[observers.file_observer]
     self.max_evaluation=option_obj.max_evaluation
     self.mutation_rate=option_obj.mutation_rate
     self.g_m=option_obj.m_gauss
     self.g_std=option_obj.std_gauss
     self.inint_T=option_obj.init_temp
     self.cooling_rate=option_obj.cooling_rate
 
     self.num_inputs=option_obj.num_inputs
     self.SetBoundaries(option_obj.boundaries)
     self.maximize=False #hard wired, always minimize
     self.stat_file=open("stat_file.txt","w")
     self.ind_file=open("ind_file.txt","w")
     #inspyred needs sequence of seeds
     #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_inputs" : self.num_inputs,"self": self})),self)]
     try:
         if isinstance(option_obj.starting_points[0],list):
             self.starting_points=option_obj.starting_points
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=None
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points
 def __init__(self,reader_obj,model_obj,option_obj,resolution):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.num_inputs=option_obj.num_inputs
     self.num_points_per_dim=resolution
     #self.resolution=5
     #print self.resolution
     self.SetBoundaries(option_obj.boundaries)
Example #4
0
 def __init__(self,reader_obj,model_obj,option_obj,resolution):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.num_params=option_obj.num_params
     self.num_points_per_dim=resolution
     #self.resolution=5
     #print self.resolution
     self.SetBoundaries(option_obj.boundaries)
Example #5
0
    def __init__(self,reader_obj,model_obj,option_obj):

        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)

        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)

	#PSO algorithm
        self.evo_strat=inspyred.swarm.PSO(self.rand)

	#algorithm terminates at max number of generations
        self.evo_strat.terminator=terminators.generation_termination

	if option_obj.output_level=="1":
            self.evo_strat.observer=[observers.population_observer,observers.file_observer]
        else:
            self.evo_strat.observer=[observers.file_observer]

        self.max_evaluation=option_obj.max_evaluation
        self.pop_size=option_obj.pop_size

	#PSO attributes
        
        self.inertia=option_obj.inertia
        self.cognitive_rate=option_obj.cognitive_rate
        self.social_rate=option_obj.social_rate
	#self.neighborhood_size=int(round(option_obj.neighborhood_size))
	self.topology=inspyred.swarm.topologies.star_topology
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        self.maximize=False #hard wired, always minimize
        self.stat_file=open("stat_file.txt","w")
        self.ind_file=open("ind_file.txt","w")

        #inspyred needs sequence of seeds
        #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
        try:
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
Example #6
0
    def __init__(self,reader_obj,model_obj,option_obj):

        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)

        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)

	#PSO algorithm
        self.evo_strat=inspyred.swarm.PSO(self.rand)

	#algorithm terminates at max number of generations
        self.evo_strat.terminator=terminators.generation_termination

	if option_obj.output_level=="1":
            self.evo_strat.observer=[observers.population_observer,observers.file_observer]
        else:
            self.evo_strat.observer=[observers.file_observer]

        self.max_evaluation=option_obj.max_evaluation
        self.pop_size=option_obj.pop_size

	#PSO attributes
        
        self.inertia=option_obj.inertia
        self.cognitive_rate=option_obj.cognitive_rate
        self.social_rate=option_obj.social_rate
	#self.neighborhood_size=int(round(option_obj.neighborhood_size))
	self.topology=inspyred.swarm.topologies.star_topology
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        self.maximize=False #hard wired, always minimize
        self.stat_file=open("stat_file.txt","w")
        self.ind_file=open("ind_file.txt","w")

        #inspyred needs sequence of seeds
        #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
        try:
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
Example #7
0
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)
        self.evo_strat=ec.DEA(self.rand)
#    - *num_selected* -- the number of individuals to be selected (default 2)
#    - *tournament_size* -- the tournament size (default 2)
#    - *crossover_rate* -- the rate at which crossover is performed
#    (default 1.0)
#    - *mutation_rate* -- the rate at which mutation is performed (default 0.1)
#    - *gaussian_mean* -- the mean used in the Gaussian function (default 0)
#    - *gaussian_stdev* -- the standard deviation used in the Gaussian function
#   (default 1)
        self.evo_strat.terminator=terminators.generation_termination

        if option_obj.output_level=="1":
            self.evo_strat.observer=[observers.population_observer,observers.file_observer]
        else:
            self.evo_strat.observer=[observers.file_observer]
        self.pop_size=option_obj.pop_size
        self.max_evaluation=option_obj.max_evaluation
        self.mutation_rate=option_obj.mutation_rate
	self.crossover_rate=option_obj.crossover_rate
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        self.maximize=False #hard wired, always minimize
        self.stat_file=open("stat_file.txt","w")
        self.ind_file=open("ind_file.txt","w")
        #inspyred needs sequence of seeds
        #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
        try:
            #print type(option_obj.starting_points)
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
Example #8
0
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)
        self.evo_strat=ec.DEA(self.rand)
#    - *num_selected* -- the number of individuals to be selected (default 2)
#    - *tournament_size* -- the tournament size (default 2)
#    - *crossover_rate* -- the rate at which crossover is performed
#    (default 1.0)
#    - *mutation_rate* -- the rate at which mutation is performed (default 0.1)
#    - *gaussian_mean* -- the mean used in the Gaussian function (default 0)
#    - *gaussian_stdev* -- the standard deviation used in the Gaussian function
#   (default 1)
        self.evo_strat.terminator=terminators.generation_termination

        if option_obj.output_level=="1":
            self.evo_strat.observer=[observers.population_observer,observers.file_observer]
        else:
            self.evo_strat.observer=[observers.file_observer]
        self.pop_size=option_obj.pop_size
        self.max_evaluation=option_obj.max_evaluation
        self.mutation_rate=option_obj.mutation_rate
	self.crossover_rate=option_obj.crossover_rate
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        self.maximize=False #hard wired, always minimize
        self.stat_file=open("stat_file.txt","w")
        self.ind_file=open("ind_file.txt","w")
        #inspyred needs sequence of seeds
        #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
        try:
            #print type(option_obj.starting_points)
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)
        self.pop_size=option_obj.pop_size
        self.num_inputs=option_obj.num_inputs
        self.SetBoundaries(option_obj.boundaries)

        try:
            #print type(option_obj.starting_points)
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=random
     self.seed=option_obj.seed
     self.rand.seed([self.seed])
     self.max_evaluation=option_obj.max_evaluation
     self.accuracy=option_obj.acc
     self.num_inputs=option_obj.num_inputs
     self.SetBoundaries(option_obj.boundaries)
     try:
         if isinstance(option_obj.starting_points[0],list):
             raise TypeError
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=uniform(self.rand,{"num_inputs" : self.num_inputs,"self": self})
         
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points
Example #11
0
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=Random()
        self.seed=option_obj.seed
        self.rand.seed(self.seed)
        self.pop_size=option_obj.pop_size
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)

        try:
            #print type(option_obj.starting_points)
            if isinstance(option_obj.starting_points[0],list):
                self.starting_points=option_obj.starting_points
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=None
        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
Example #12
0
    def __init__(self,reader_obj,model_obj,option_obj):
        self.fit_obj=fF(reader_obj,model_obj,option_obj)
        self.SetFFun(option_obj)
        self.rand=random
        self.seed=option_obj.seed
        self.rand.seed([self.seed])
        self.max_evaluation=option_obj.max_evaluation
        self.accuracy=option_obj.acc
        self.num_params=option_obj.num_params
        self.SetBoundaries(option_obj.boundaries)
        try:
            if isinstance(option_obj.starting_points[0],list):
                raise TypeError
            else:
                self.starting_points=[normalize(option_obj.starting_points,self)]
        except TypeError:
            self.starting_points=uniform(self.rand,{"num_params" : self.num_params,"self": self})

        if option_obj.output_level=="1":
            print "starting points: ",self.starting_points
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=random
     self.seed=option_obj.seed
     self.rand.seed([self.seed])
     self.temp=option_obj.temperature
     self.num_iter=option_obj.num_iter
     self.num_repet=option_obj.num_repet
     self.step_size=option_obj.step_size
     self.freq=option_obj.update_freq
     self.num_inputs=option_obj.num_inputs
     self.SetBoundaries(option_obj.boundaries)
     try:
         if isinstance(option_obj.starting_points[0],list):
             self.starting_points=option_obj.starting_points
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=uniform(self.rand,{"num_inputs" : self.num_inputs,"self": self})
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points
Example #14
0
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=random
     self.seed=option_obj.seed
     self.rand.seed([self.seed])
     self.temp=option_obj.temperature
     self.num_iter=option_obj.num_iter
     self.num_repet=option_obj.num_repet
     self.step_size=option_obj.step_size
     self.freq=option_obj.update_freq
     self.num_params=option_obj.num_params
     self.SetBoundaries(option_obj.boundaries)
     try:
         if isinstance(option_obj.starting_points[0],list):
             self.starting_points=option_obj.starting_points
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=uniform(self.rand,{"num_params" : self.num_params,"self": self})
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=Random()
     self.seed=option_obj.seed
     self.rand.seed(self.seed)
     self.evo_strat=ec.ES(self.rand)
     self.evo_strat.terminator=terminators.generation_termination
     self.evo_strat.selector=inspyred.ec.selectors.default_selection
     self.evo_strat.replacer=inspyred.ec.replacers.generational_replacement
     self.evo_strat.variator=[variators.gaussian_mutation,
                              variators.blend_crossover]
     if option_obj.output_level=="1":
         self.evo_strat.observer=[observers.population_observer,observers.file_observer]
     else:
         self.evo_strat.observer=[observers.file_observer]
     self.pop_size=option_obj.pop_size
     self.max_evaluation=option_obj.max_evaluation
     self.mutation_rate=option_obj.mutation_rate
     self.num_inputs=option_obj.num_inputs
     self.SetBoundaries(option_obj.boundaries)
     self.maximize=False #hard wired, always minimize
     self.stat_file=open("stat_file.txt","w")
     self.ind_file=open("ind_file.txt","w")
     #inspyred needs sequence of seeds
     #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_inputs" : self.num_inputs,"self": self})),self)]
     try:
         #print type(option_obj.starting_points)
         if isinstance(option_obj.starting_points[0],list):
             self.starting_points=option_obj.starting_points
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=None
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points
Example #16
0
 def __init__(self,reader_obj,model_obj,option_obj):
     self.fit_obj=fF(reader_obj,model_obj,option_obj)
     self.SetFFun(option_obj)
     self.rand=Random()
     self.seed=option_obj.seed
     self.rand.seed(self.seed)
     self.evo_strat=ec.ES(self.rand)
     self.evo_strat.terminator=terminators.generation_termination
     self.evo_strat.selector=inspyred.ec.selectors.default_selection
     self.evo_strat.replacer=inspyred.ec.replacers.generational_replacement
     self.evo_strat.variator=[variators.gaussian_mutation,
                              variators.blend_crossover]
     if option_obj.output_level=="1":
         self.evo_strat.observer=[observers.population_observer,observers.file_observer]
     else:
         self.evo_strat.observer=[observers.file_observer]
     self.pop_size=option_obj.pop_size
     self.max_evaluation=option_obj.max_evaluation
     self.mutation_rate=option_obj.mutation_rate
     self.num_params=option_obj.num_params
     self.SetBoundaries(option_obj.boundaries)
     self.maximize=False #hard wired, always minimize
     self.stat_file=open("stat_file.txt","w")
     self.ind_file=open("ind_file.txt","w")
     #inspyred needs sequence of seeds
     #self.starting_points=[normalize(args.get("starting_points",uniform(self.rand,{"num_params" : self.num_params,"self": self})),self)]
     try:
         #print type(option_obj.starting_points)
         if isinstance(option_obj.starting_points[0],list):
             self.starting_points=option_obj.starting_points
         else:
             self.starting_points=[normalize(option_obj.starting_points,self)]
     except TypeError:
         self.starting_points=None
     if option_obj.output_level=="1":
         print "starting points: ",self.starting_points