Issue with MaterialGuidePlan and getMaterialAmountRange in OptaPlanner

62 views
Skip to first unread message

624231081

unread,
Jul 8, 2023, 6:46:30 AM7/8/23
to optaplanner-dev

Dear OptaPlanner development team,


I am writing to seek your assistance regarding an issue I encountered while using OptaPlanner. In my implementation, I have defined a class called MaterialGuidePlan where both material and amount are planning variables.


The amount variable represents the quantity of a material to be used, which needs to be dynamically determined based on the total count of materials available in the material object. However, during the planning process, there is a possibility that the material variable has not been assigned yet, resulting in material == null.


To handle this scenario, I implemented the getMaterialAmountRange method as follows:


@ValueRangeProvider(id = "materialAmountRange")

public CountableValueRange<Integer> getMaterialAmountRange() {

    if(material == null){

        return new ListValueRange<>(List.of(0));

    }

    int max = material.getTotalAmount() - material.getPlanAmount() - material.getLockedAmount();

    return new IntValueRange(0, max);

}


However, this implementation is causing an exception in the results. On the other hand, if I use return new IntValueRange(0, Integer.MAX_VALUE);, the results are normal. Nevertheless, this approach leads to a large search space and reduced efficiency. I am unsure how to proceed in order to address this issue effectively.


I would greatly appreciate any guidance or suggestions you can provide to help me resolve this problem. Thank you for your attention and support.


Sincerely,

Ericbin

陈伟斌

unread,
Jul 8, 2023, 6:47:46 AM7/8/23
to optaplanner-dev
Reply all
Reply to author
Forward
0 new messages