Optaplanner构造启发式阶段唯一值范围
我正在为解决方案域优化构造启发式 我有一个Optaplanner构造启发式阶段唯一值范围,optaplanner,Optaplanner,我正在为解决方案域优化构造启发式 我有一个ValueRangerProvider,如下所示 @ValueRangeProvider(id=“timeRange”) public CountableValueRange时间范围(){ final LocalDateTime start=LocalDateTime.now().plusHours(1.truncatedTo(ChronoUnit.HOURS); final LocalDateTime end=LocalDateTime.now().p
ValueRangerProvider
,如下所示
@ValueRangeProvider(id=“timeRange”)
public CountableValueRange时间范围(){
final LocalDateTime start=LocalDateTime.now().plusHours(1.truncatedTo(ChronoUnit.HOURS);
final LocalDateTime end=LocalDateTime.now().plusYears(1.truncatedTo(ChronoUnit.HOURS);
返回Stream.iterate(开始,d->d.plusHours(1))
.takeWhile(localDateTime->localDateTime.isBefore(end))
.collect(Collectors.toList());
}
此@ValueRangeProvider
为时间粒度
模型中使用的开始和结束之间的每小时提供LocalDateTime
实例。timeRange
值范围是@PlanningEntity
类中唯一的@planningvariable
我还有以下solverConfig.xml
:
org.acme.optaplanner.solver.MyConstraintProvider
只剩下你了
真的
初试
起初的
在构造启发式过程中,对象初始化比解的质量更重要。如果有足够的时间段,则不会出现硬约束
我意识到前面步骤中使用的@ValueRangeProvider(id=“timeRange”)
值将在构建启发式过程中的后续步骤中重新使用
1772 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase - CH step (0), time spent (157), score (-999init/0hard/-1soft), selected move count (1), picked move (Lesson{id=1, subject='Math I', pinned=false, startTime=null, durationInGrains=3} {null -> 2020-09-27T09:00}).
.
.
.
02:01:26.494 [main ] DEBUG CH step (497), time spent (14513), score (-502init/0hard/-5542soft), selected move count (664), picked move (Lesson{id=498, subject='Math I', pinned=false, startTime=null, durationInGrains=3} {null -> 2020-11-10T12:00}).
02:01:26.565 [main ] DEBUG CH step (498), time spent (14584), score (-501init/0hard/-5548soft), selected move count (666), picked move (Lesson{id=499, subject='Math I', pinned=false, startTime=null, durationInGrains=1} {null -> 2020-11-10T14:00}).
.
.
.
17456 [main] TRACE o.o.c.i.c.d.ConstructionHeuristicDecider - Move index (0), score (-500init/-2hard/-5571soft), move (Lesson{id=500, subject='Math I', pinned=false, startTime=null, durationInGrains=2} {null -> 2020-09-27T09:00}).
.
.
.
02:01:26.637 [main ] DEBUG CH step (499), time spent (14656), score (-500init/0hard/-5557soft), selected move count (667), picked move (Lesson{id=500, subject='Math I', pinned=false, startTime=null, durationInGrains=2} {null -> 2020-11-10T15:00}).
02:01:26.711 [main ] DEBUG CH step (500), time spent (14730), score (-499init/0hard/-5568soft), selected move count (668), picked move (Lesson{id=501, subject='Math I', pinned=false, startTime=null, durationInGrains=3} {null -> 2020-11-10T16:00}).
02:01:26.787 [main ] DEBUG CH step (501), time spent (14806), score (-498init/0hard/-5581soft), selected move count (670), picked move (Lesson{id=502, subject='Math I', pinned=false, startTime=null, durationInGrains=1} {null -> 2020-11-10T18:00}).
.
.
.
02:17:46.156 [main ] INFO Construction Heuristic phase (0) ended: time spent (98518), best score (0hard/-11165soft), score calculation speed (6783/sec), step total (1000).
02:17:46.165 [main ] INFO Solving ended: time spent (98527), best score (0hard/-11165soft), score calculation speed (6776/sec), phase total (2), environment mode (NON_REPRODUCIBLE).
2020-10-01T09:00的LocalDateTime
用于CH步骤(0)和CH步骤(499)
由于我有一个硬约束,约束两个@PlanningEntity
不能使用相同的时间范围
值,我想知道是否可以删除所使用的时间范围值以供将来的步骤使用
例如,
我已经更改了构造启发式
配置
初试
随机的
第一,可行的,得分的,或不难的
这导致了非常快速的构造启发式性能,因为该步骤是随机选择@Planningvariables
作为@PlanningRangeProvider
.
.
.
2535 [main] TRACE o.o.c.i.c.d.ConstructionHeuristicDecider - Move index (0), score (-2init/0hard/-3303soft), move (Lesson{id=998, subject='Math I', pinned=false, startTime=null, durationInGrains=2} {null -> 2020-10-13T20:00}).
2535 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase - CH step (997), time spent (1046), score (-2init/0hard/-3303soft), selected move count (1), picked move (Lesson{id=998, subject='Math I', pinned=false, startTime=null, durationInGrains=2} {null -> 2020-10-13T20:00}).
2536 [main] TRACE o.o.c.i.c.d.ConstructionHeuristicDecider - Move index (0), score (-1init/0hard/-3312soft), move (Lesson{id=999, subject='Math I', pinned=false, startTime=null, durationInGrains=3} {null -> 2021-08-26T22:00}).
2536 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase - CH step (998), time spent (1047), score (-1init/0hard/-3312soft), selected move count (1), picked move (Lesson{id=999, subject='Math I', pinned=false, startTime=null, durationInGrains=3} {null -> 2021-08-26T22:00}).
2537 [main] TRACE o.o.c.i.c.d.ConstructionHeuristicDecider - Move index (0), score (0hard/-3317soft), move (Lesson{id=1000, subject='Math I', pinned=false, startTime=null, durationInGrains=1} {null -> 2021-03-10T15:00}).
2537 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase - CH step (999), time spent (1048), score (0hard/-3317soft), selected move count (1), picked move (Lesson{id=1000, subject='Math I', pinned=false, startTime=null, durationInGrains=1} {null -> 2021-03-10T15:00}).
2540 [main] INFO o.o.c.i.c.DefaultConstructionHeuristicPhase - Construction Heuristic phase (0) ended: time spent (1051), best score (0hard/-3317soft), score calculation speed (1304/sec), step total (1000).
2549 [main] INFO o.o.core.impl.solver.DefaultSolver - Solving ended: time spent (1059), best score (0hard/-3317soft), score calculation speed (1169/sec), phase total (2), environment mode (NON_REPRODUCIBLE).
是否有足够的方法限制步骤使用预先使用的值范围?会有任何退让吗