我正在尝试使用模拟退火/水流购买来根据该语法找到语法对象的最小描述长度和数据。
我自己定义语法对象,以及copyDocs.mustRunAfter build
(这是语法上的变异):
take_step
问题:我收到错误:
def total_energy(self, grammar_and_data): #the objective function
# ...operations....
return encoder.totalLength(grammar,data)
def optimize(self, data):
initial_grammar_and_data = array((initial_grammar, data))
take_mutation = MyTakeStep()
ret = basinhopping(self.total_energy,
initial_grammar_and_data,
niter=100,
T=1.0,
#stepsize=0.5,
#minimizer_kwargs=None,
take_step=take_mutation,
#accept_test=None,
#callback=None,
#interval=50,
#disp=False,
#niter_success=None
)
为了找到目标函数当前值附近的邻居,我怎样才能使算法引用单步函数?这里不能确定一个小步长。
也许盆地跳跃不能用于非数字参数? 如果是这样,你是否知道Python中的通用模拟退火算法可以解决这个问题(我可以自己写一个,但它的效率远低于scipy ......)?