optapy / optapy

OptaPy is an AI constraint solver for Python to optimize planning and scheduling problems.

Home Page:https://www.optapy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug `@value_range_provider` type must match `@planning_variable` type

Christopher-Chianelli opened this issue · comments

Currently, the following code with throw a class cast exception:

@optapy.problem_fact
class Slot:
    pass


@optapy.planning_entity
class Task:
    # ...
    @optapy.planning_variable(Slot, value_range_providers=['value_range_provider']
    def get_value(self):
        return self.value


@optapy.planning_solution
class Solution:
    # ...
    @optapy.planning_entity_collection(Task)
    @optapy.value_range_provider('value_range_provider')
    def get_tasks(self):
        return self.tasks

That is, although Task is a subclass of Slot, specifying it as the type of a value range causes an exception. Ideally,
@value_range_provider would allow specifying subclasses of the @planning_variable type