本文介绍了OptaPlanner:ValueSelector不能使用ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ConstructionHeuristic阶段使用MoveSelector配置。
在EntitySelector中配置filterClass和comparatorClass可以正常工作。

I am using MoveSelector configuration in the ConstructionHeuristic Phase. It works fine with configuring filterClass and comparatorClass in EntitySelector.

但是,在ValueSelector会话中,我不能使用ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY规划变量。
它抛出此异常:
java.lang.IllegalArgumentException :具有resolvedCacheType(PHASE)和resolvedSelectionOrder(SORTED)的valueSelectorConfig(ValueSelectorConfig(row))需要基于EntityIndependentValueSelector(FromEntityPropertyValueSelector(row))。检查您的@ValueRangeProvider注释。

However, in ValueSelector session, I am not able to use "ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY" planning variable.It throws this exception:java.lang.IllegalArgumentException: The valueSelectorConfig (ValueSelectorConfig(row)) with resolvedCacheType (PHASE) and resolvedSelectionOrder (SORTED) needs to be based on a EntityIndependentValueSelector (FromEntityPropertyValueSelector(row)). Check your @ValueRangeProvider annotations.

示例NQueen配置:
...

Example NQueen Config:...

<changeMoveSelector>
    <entitySelector mimicSelectorRef="placerEntitySelector">
    </entitySelector>
    <valueSelector>
       <variableName>row</variableName>
       <cacheType>PHASE</cacheType>
       <selectionOrder>SORTED</selectionOrder>
       <sorterComparatorClass>..RowWeightStrength</sorterComparatorClass>
    </valueSelector>
</changeMoveSelector>

....

**我需要使用valueRange取决于我的计划实体为了使用PossibleRowList为每个女王(为了性能)
任何建议吗?提前感谢。

** I need to use the valueRange depends on my planning Entity in order to use PossibleRowList for each Queen (for the performance sake)Any suggestion please? Thanks in advance.

推荐答案

valueSelector是SORTED,所以需要缓存(以便能够对它们进行排序)。

That valueSelector is SORTED, so it needs to cache (to be able to sort them). But caching with a @ValueRangeProvider per entity is not supported if I recall correctly.

这意味着每个实体的@ValueRangeProvider的CH只支持FIRST_FIT和FIRST_FIT_DECREASING,但不支持WEAKEST_FIT或STRONGEST_FIT。我相信有一个jira这已经(如果你找到它,链接它在这里)。我们需要解决这个问题。

This implies that the CH with a @ValueRangeProvider per entity only supports FIRST_FIT and FIRST_FIT_DECREASING, but not WEAKEST_FIT or STRONGEST_FIT. I believe there's a jira for this already (do link it here if you find it). We need to fix this.

同时:一个解决方法是不使用SORTED,但已经在每个实体的值范围列表中排序。

Meanwhile: a workaround would be to not use SORTED, but already sort them in each entity's value range list.

这篇关于OptaPlanner:ValueSelector不能使用ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 07:12