PlanningEntity in OptaPlanner
Posted By : Mohit Jain | 21-Jul-2018
Here actually, we need to understand what is the actual role of
We have 3 Main classes(Entity's) in optaPlanner
1. PlanningEntity:- Point of concern here.
2. PlanningFact:- Detailed discussion will be discussed later in other blogs.
3.)PlanningProblem(after solving also called as PlanningSolution): Detailed discussion will be discussed later in other blogs.
1.) PlanningEntity:-
This the Entity which is actually assigned across PlanningFact.
Remember:- Beacuse it is actually confusing but if you understand once you will never face problem to think.
Our PlanningEntity must always be annotated with @PlanningEntity Annotation but it is not always true that @PlanningEntity annotated class is a always act as PlanningEntity for our PlanningProblem because it may act as PlanningFact even though it is annoted with @PlanningEntity annotation.
So, actually what makes PlanningEntity to be acted as PlanningEntity of our PlanningProblem.
There are 3 Places(Syntax) which defines that this is actually PlanningEntity in terms of optaplanner so that optaplanner will able to treat it as planningEntity for PlanningFact's:-
1.)It must be annotated with @PlanningEntity annotation.
2.)It must be in SolverConfiguation.xml file as follows:-
<solver>
<solutionClass>
</solutionClass><entityClass>Our PlanningEntity for PlanningProblem</entityClass>
</solver>
3.)It must be annotated with @PlanningEntityCollectionProperty whenever, it is defined within @ProblemSolution annotated class (final step).If any of the step is missing it will not be treated as PlanningEntity by optaplanner for planning..
Note:- All 3 above steps are cumpulsory but optaplanner determines PlanningEntity actually looking inside @ProblemSolution annotated class having annotation @PlanningEntityCollectionProperty
For example 1:- In CloudBalance example by opataplanner all above steps are present
@PlanningSolution
@XStreamAlias("CloudBalance")
public class CloudBalance extends AbstractPersistable {
@PlanningEntityCollectionProperty
public List<CloudProcess> getProcessList() {
return processList;
}
public void setProcessList(List<CloudProcess> processList) {
this.processList = processList;
}
}
For example 2:- In DinnerPary example by opataplanner all above steps are present
@PlanningSolution
@XStreamAlias("DinnerParty")
public class DinnerParty extends AbstractPersistable {
@PlanningEntityCollectionProperty
public List<SeatDesignation> getSeatDesignationList() {
return seatDesignationList;
}
public void setSeatDesignationList(List<SeatDesignation> seatDesignationList) {
this.seatDesignationList = seatDesignationList;
}
}
For example 3:- In TaskAssigning example by opataplanner all above steps are present
@PlanningSolution
@XStreamAlias("TaTaskAssigningSolution")
public class TaskAssigningSolution extends AbstractPersistable {
@PlanningEntityCollectionProperty
@ValueRangeProvider(id = "taskRange")
private List<Task> taskList;
}
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Mohit Jain
Mohit Jain working as backend java developer having knowlege of core java,spring,hibernate.