我正在尝试运行solver_manager_create方法,如optapy (https://github.com/optapy/optapy-quickstarts/blob/04fd102ee31919cacc4145d0517fe07b2627ca02/employee-scheduling/services.py#L168)中的快速启动代码所示。
SINGLETON_ID = 1
solver_config = optapy.config.solver.SolverConfig()
solver_config\
.withSolutionClass(EmployeeSchedule)\
.withEntityClasses(Shift)\
.withConstraintProviderClass(employee_scheduling_constraints)\
.withTerminationSpentLimit(Duration.ofSeconds(60))
#error occurs in this line
solver_manager = solver_manager_create(solver_config)但是我收到了一个java.lang.IllegalArgumentException错误。
完全错误:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot use class (org.optaplanner.optapy.generated.class6.domain.Shift.GeneratedClass) in a constraint stream as it is neither the same as, nor a superclass or superinterface of one of planning entities or problem facts.
Ensure that all from(), join(), ifExists() and ifNotExists() building blocks only reference classes assignable from planning entities or problem facts ([org.optaplanner.optapy.generated.class0.shift_planning.domain.Employee.GeneratedClass, org.optaplanner.optapy.generated.class1.shift_planning.domain.ConstraintForTag.GeneratedClass, org.optaplanner.optapy.generated.class2.shift_planning.domain.Shift.GeneratedClass]) annotated on the planning solution (org.optaplanner.optapy.generated.class3.shift_planning.domain.EmployeeSchedule.GeneratedClass).我遗漏了什么?
发布于 2022-10-11 20:05:05
从错误消息来看,约束流使用一个版本的Shift,域模型使用不同版本的Shift。不要重新定义或定义实体类/问题事实类的多个版本:它们将被视为彼此不同。注意,...domain.Shift... (由约束流使用的)与...shift_planning.domain.Shift... (由域使用的)不同。要么在约束流中使用domain.Shift,要么在域中使用shift_planning.domain.Shift。
https://stackoverflow.com/questions/74030316
复制相似问题