Bi-directional variable (inverse relation shadow variable) won’t work in python because of object comparison #1183
Closed
binarymind
started this conversation in
General
Replies: 2 comments
-
I think there is a bug here, but oddly enough, the bug is only triggered when the class with I think the following code will work: @planning_entity
class Eleve(JsonDomainBase):
id: Annotated[str, PlanningId]
name: str
barrette: Annotated[Optional["Barrette"],
PlanningVariable,
IdSerializer,
BarretteValidator,
Field(default=None)]
def __eq__(self, o):
return self.id == o.id
def __hash__(self):
return hash(self.id)
@planning_entity
class Barrette(JsonDomainBase):
id: Annotated[str, PlanningId]
name:str
eleves: Annotated[
list[Eleve],
InverseRelationShadowVariable(source_variable_name ="barrette"),
IdListSerializer,
EleveListValidator,
Field(default_factory=list)
]
@planning_solution
class Timetable(JsonDomainBase):
id: str
barrettes: Annotated[list[Barrette],
PlanningEntityCollectionProperty,
ValueRangeProvider]
eleves: Annotated[list[Eleve],
PlanningEntityCollectionProperty]
score: Annotated[HardSoftScore | None,
PlanningScore,
ScoreSerializer,
ScoreValidator,
Field(default=None)]
solver_status: Annotated[SolverStatus, Field(default=SolverStatus.NOT_SOLVING)] |
Beta Was this translation helpful? Give feedback.
0 replies
-
OMG it indeed seems to work !!!! thanks mate you saved me |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a problem : I am in python and try to code the equivalent of :
and
1 - I can’t find any snippet with the full working code of this : a real planningVariable and a list of the shadowVariable
something with the full code of the doc
2 - my problem is that when timefold add the entity in the shadow variable after the allocation it can’t detect it and tell me :
here is my domain.py
here is json_serialization.py :
generate the error
3 - if I try to add eq function in the entities it tells me
If someone have any lead to help me that would be awesome
cheers
Beta Was this translation helpful? Give feedback.
All reactions