本文整理汇总了Python中solution.Solution.length_function方法的典型用法代码示例。如果您正苦于以下问题:Python Solution.length_function方法的具体用法?Python Solution.length_function怎么用?Python Solution.length_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solution.Solution
的用法示例。
在下文中一共展示了Solution.length_function方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: combine
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import length_function [as 别名]
def combine(self, s1, s2):
sn = Solution()
sn.length_function = copy.deepcopy(s1.length_function) if random() > 0.5 else copy.deepcopy(s2.length_function)
sn.radiance_function = copy.deepcopy(s1.radiance_function) if random() > 0.5 else copy.deepcopy(s2.radiance_function)
sn.orientation_function = copy.deepcopy(s1.orientation_function) if random() > 0.5 else copy.deepcopy(s2.orientation_function)
sn.termination_function = copy.deepcopy(s1.termination_function) if random() > 0.5 else copy.deepcopy(s2.termination_function)
return sn
示例2: new_solution
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import length_function [as 别名]
def new_solution(self):
def random_term():
return createTerm('Random', innerMultiplier=uniform(-2.0, 2.0), outerMultiplier=uniform(-3.0, 3.0))
s = Solution()
s.length_function = Expression(init_terms=[random_term()])
s.radiance_function = Expression(init_terms=[random_term()])
s.orientation_function = Expression(init_terms=[random_term()])
s.termination_function = Expression(init_terms=[random_term()])
return s
示例3: __init__
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import length_function [as 别名]
def __init__(self):
self.fittest = None
self.generation = 0
initial_solution = Solution()
initial_solution.length_function = Expression(init_terms=[createTerm('Constant', innerMultiplier=3.0, outerMultiplier=3.0)])
initial_solution.radiance_function = Expression(init_terms=[createTerm('Constant', innerMultiplier=1.0, outerMultiplier=1.5)])
initial_solution.orientation_function = Expression(init_terms=[createTerm('Constant', innerMultiplier=-0.1, outerMultiplier=0.1)])
initial_solution.termination_function = Expression(init_terms=[createTerm('Constant', innerMultiplier=3.0, outerMultiplier=3.0)])
self.solutions = [initial_solution]
workers = cfg.getint('FitnessTest', 'workers')
if workers > 1:
print "Evaluating using {workers} worker threads".format(workers=workers)
self.map = Pool(processes=workers).map_async
else:
self.map = map
self.max_fitness_acheived = 0