我试图使用阴影变量,但我不确定我是否理解如何才能正确地更新它们的值。OptaPlanner的文档表明,要更新影子变量,OptaPlanner使用VariableListener,但在optapy中似乎还不支持。我是不是读错了,我不需要一个VariableListener?
如果我在光学文档中使用这个例子:
from optapy import planning_entity, planning_variable
from optapy.types import PlanningVariableGraphType
@planning_entity
class Customer:
@planning_variable(object, graph_type = PlanningVariableGraphType.CHAINED, ...)
def get_previous_standstill(self):
return self.previous_standstill
def set_previous_standstill(previous_standstill):
...
from optapy import planning_entity, inverse_relation_shadow_variable
@planning_entity
class Standstill:
@inverse_relation_shadow_variable(Customer, source_variable_name ="previous_standstill")
def get_next_customer(self):
return self.next_customer
def set_next_customer(Customer nextCustomer):
...变量next_customer是如何更新的?
发布于 2022-05-25 13:45:47
当前不支持自定义阴影变量(使用自定义VariableListeners) (跟踪问题:https://github.com/optapy/optapy/issues/75),但是内置阴影变量(使用预定义的VariableListeners)支持。内置阴影变量是:@inverse_relation_shadow_variable,当源变量接受对象作为值时更新;@anchor_shadow_variable更新,当源链式变量的链开始发生变化时。
在上面的示例中,如果我有一个暂停的standstill,那么每当OptaPy通过customer.set_previous_standstill(standstill)更新客户customer时,都会调用standstill.set_next_customer(customer)。
https://stackoverflow.com/questions/72368901
复制相似问题