Planning Entities
Define planning entities that the solver will optimize.
Domain modeling is the foundation of any SolverForge application. You define your problem structure using Python dataclasses and type annotations.
A typical SolverForge model consists of:
Planning Solution
├── Problem Facts (immutable data)
│ ├── Timeslots, Rooms, Employees, etc.
│ └── Value Range Providers
├── Planning Entities (mutable)
│ └── Planning Variables (assigned by solver)
└── Score (calculated from constraints)
@planning_entity
@dataclass
class Lesson:
id: Annotated[str, PlanningId]
subject: str
teacher: str
# Planning variables - assigned by the solver
timeslot: Annotated[Timeslot | None, PlanningVariable] = field(default=None)
room: Annotated[Room | None, PlanningVariable] = field(default=None)
@planning_solution
@dataclass
class Timetable:
# Problem facts - immutable
timeslots: Annotated[list[Timeslot], ProblemFactCollectionProperty, ValueRangeProvider]
rooms: Annotated[list[Room], ProblemFactCollectionProperty, ValueRangeProvider]
# Planning entities - contain variables to optimize
lessons: Annotated[list[Lesson], PlanningEntityCollectionProperty]
# Score - calculated by constraints
score: Annotated[HardSoftScore, PlanningScore] = field(default=None)
Define planning entities that the solver will optimize.
Define what the solver assigns: simple variables and list variables.
Define the container for problem data and solution score.
Define calculated variables that update automatically.
Lock specific assignments to prevent the solver from changing them.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.