def evaluate(self, global_decision_vector = None, local_decision_vector = None): # import statements from revenue import calculate_revenue from cost import calculate_cost # setting global decision vector if global_decision_vector == None: self.set_global_decisions() else: self.set_global_decisions(global_decision_vector) # setting local decision vector if local_decision_vector == None: self.set_local_decisions() else: self.set_local_decisions(local_decision_vector) # execute the mission self.execute() # call the revenue function, which calculates the #+ revenue generated by the mission calculate_revenue(self) # call the cost function, which calculates the cost #+ of the mission calculate_cost(self) # add a 'profit' attribute to the mission self.profit = self.revenue - self.cost
def _evaluate(self, decision_vector): # import statements import solarsystem_objects_parameters as ss from numpy.linalg import norm from numpy import array from copy import copy, deepcopy from revenue import calculate_revenue from cost import calculate_cost from time import sleep # make a copy of the actual mission and its ntr to optimize on mission_copy = deepcopy(self) mission_copy.set_local_decisions(decision_vector) # debug print statements if self.DEBUG: print ('\n ---- Starting a New Iteration ---- \n') if self.DEBUG: print ('--- Memory Locations ---') if self.DEBUG: print (' mission level ') if self.DEBUG: print mission_copy if self.DEBUG: print self if self.DEBUG: print '' if self.DEBUG: print (' 1 sub level ') if self.DEBUG: print mission_copy.ntr if self.DEBUG: print self.ntr if self.DEBUG: print '' if self.DEBUG: print (' 1 obj sub level 1 attribute level ') if self.DEBUG: print hex(id(mission_copy.ntr.mass)) if self.DEBUG: print hex(id(self.ntr.mass)) if self.DEBUG: print '' if self.DEBUG: print (' 2 obj sub levels ') if self.DEBUG: print mission_copy.ntr.core if self.DEBUG: print self.ntr.core if self.DEBUG: print '' if self.DEBUG: print (' 2 obj ') if self.DEBUG: print ('-----------------------') if self.DEBUG: print mission_copy.ntr.mass if self.DEBUG: print ('self.nso_altitude is: %f ' %self.nso_altitude) if self.DEBUG: print ('copy.nso_altitude is: %f ' %mission_copy.nso_altitude) if self.DEBUG: print ('nso_altitude: %.12f ' %decision_vector[0]) if self.DEBUG: print ('self.ntr.sma %f ' %self.ntr.sma) if self.DEBUG: print ('copy.ntr.sma %f ' %mission_copy.ntr.sma) if self.DEBUG: print ('mission_copy parameters') if self.DEBUG: print ('core thrust is: %f ' %mission_copy.ntr.core.thrust) if self.DEBUG: print ('core mass is: %f ' %mission_copy.ntr.core.mass) if self.DEBUG: print ('ntr mass is: %f ' %mission_copy.ntr.mass) if self.DEBUG: print ('self parameters') if self.DEBUG: print ('core thrust is: %f ' %self.ntr.core.thrust) if self.DEBUG: print ('core mass is: %f ' %self.ntr.core.mass) if self.DEBUG: print ('ntr mass is: %f ' %self.ntr.mass) if self.DEBUG: print 'sleep.....' if self.DEBUG: sleep(5.0) # execute the mission mission_copy.execute() # calculate if feasible/infeasible pass # call the revenue function, which calculates the #+ revenue generated by the mission calculate_revenue(mission_copy) # call the cost function, which calculates the cost #+ of the mission calculate_cost(mission_copy) # add a 'profit' attribute to the mission mission_copy.profit = mission_copy.revenue - mission_copy.cost # return the mission profit to the inner-loop solver # return mission_copy.profit if self.DEBUG: print ('Delta-V: %8.5f ' %(norm(array(mission_copy.ntr.dv1)))) #+ norm(array(self.ntr.dv2)) return norm(array(mission_copy.ntr.dv1)) # + norm(array(mission_copy.ntr.dv2))