计划变量不支持收集 [英] planning variable not support Collect

查看:83
本文介绍了计划变量不支持收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,一个订单有很多工艺品,其中一个工艺品需要两个或多个人才能完成,所以在规划实体中我使用了一个列表对象来规划变量,但是当我启动应用程序时,它有一个错误,请给我一些想法,谢谢!

i have a question,one order have many crafts, one of the crafts need two or many people to finish,so in the planning entity i usee a list object for planning variables,but when i start the application,it have a error,please give me some idea,thanks!

@PlanningSolution
public class ScheduleSolution extends AbstractPersistable {
@ProblemFactCollectionProperty
private List<Order> orderList;
@ProblemFactCollectionProperty
private List<ProductBom> productBomList;
@PlanningEntityCollectionProperty
private List<JobAssignment> jobAssignmentList;
@ProblemFactCollectionProperty
@ValueRangeProvider(id = "resourceRange")
List<Resource> resourceList;
@PlanningScore
private HardSoftScore score;
}

@PlanningEntity
public class JobAssignment extends AbstractPersistable {
private ProductBom productBom;
@PlanningVariable(valueRangeProviderRefs = { "resourceRange" })
private List<Resource> resourceList;
}

Caused by: java.lang.IllegalArgumentException: entityClass (class com.demo.domain.reassign.JobAssignment) 有一个 PlanningVariable 注释属性 (resourceList),它引用一个 ValueRangeProvider 注释成员(字段 java.util.List com.demo.domain.reassign.ScheduleSolution.resourceList) 返回一个集合,其元素类型(类 com.demo.domain.reassign.Resource)不能分配给 PlanningVariable 的类型(接口 java.util.List).在 org.optaplanner.core.impl.domain.valuerange.descriptor.AbstractFromPropertyValueRangeDescriptor.processValueRangeProviderAnnotation(AbstractFromPropertyValueRangeDescriptor.java:136)

Caused by: java.lang.IllegalArgumentException: The entityClass (class com.demo.domain.reassign.JobAssignment) has a PlanningVariable annotated property (resourceList) that refers to a ValueRangeProvider annotated member (field java.util.List com.demo.domain.reassign.ScheduleSolution.resourceList) that returns a Collection with elements of type (class com.demo.domain.reassign.Resource) which cannot be assigned to the PlanningVariable's type (interface java.util.List). at org.optaplanner.core.impl.domain.valuerange.descriptor.AbstractFromPropertyValueRangeDescriptor.processValueRangeProviderAnnotation(AbstractFromPropertyValueRangeDescriptor.java:136)

推荐答案

@PlanningVariable 不能是 List,直到有一天我们支持 @PlanningVariableCollection.可能的修复:

A @PlanningVariable cannot be a List, not until we support @PlanningVariableCollection some day. Possible fix:

@PlanningEntity
public class JobAssignment extends AbstractPersistable {
private ProductBom productBom;
@PlanningVariable(valueRangeProviderRefs = { "resourceRange" })
private Resource resource;
}

这篇关于计划变量不支持收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆