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