Reputation: 503
I'm looking to solve a problem very similar to the Project Job Scheduling example provided by optaplanner here (I didn't find any code related to that example - if it exists it would help me a lot).
I have designed the solution using 3 classes.
I have the Project
class, which contains a date before which it cannot start, a name, and a list of Task
.
The task is my PlanningEntity
and contains an id, name, duration, list of previous tasks and a required resource type.
Its PlanningVariable
s are a start date and a Resource
.
A resource can represent a person or tool and has a defined type.
My PlanningSolution
is defined as such :
@PlanningSolution
public class TimeTable {
@ValueRangeProvider(id = "resourceRange")
@ProblemFactCollectionProperty
private List<Resource> resourceList;
@ValueRangeProvider(id = "startRange")
@ProblemFactCollectionProperty
private List<LocalDate> dates;
@ValueRangeProvider(id = "projectRange")
@ProblemFactCollectionProperty
private List<Project> projectList;
@PlanningEntityCollectionProperty
private List<Task> taskList;
@PlanningScore
private HardSoftScore score;
// ...
}
This design allowed me to write my constraints easily (a task can't start before its previous ones are finished ; a task is assigned the correct resource ; a resource can't be assigned to different tasks on the same day ; minimize the time between two tasks), but the tasks contained in my Project
class have not changed after solving.
Only the tasks in the global taskList
will have their PlanningVariable
s set correctly.
How can I remedy that ?
I have thought about making the project a PlanningEntity
as well, but it really doesn't have any variable to plan inside. I also looked at shadow variables but as I understood it this is not what they are used for.
Upvotes: 0
Views: 69
Reputation: 1029
If I understand your domain model correctly, each project contains a subset of all the tasks. This assignment of tasks to projects is fixed.
If you are saying these project.taskList
s don't show any changes after solving, while the taskList
located in the TimeTable
does, I would check what instances of Task
s the project.taskList
s contain. All these project.taskList
s should point to the Task
instances from the TimeTable.taskList
.
Upvotes: 1