• PlanningEntity in OptaPlanner

    Posted by Mohit Jain | Last Updated: 24-Jan-19

    Here actually, we need to understand what is the actual role of PlanningEntity in terms of  OptaPlanner which seems very confusing during Domain-Modeling of Planning problem. 


    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:-



    </solutionClass><entityClass>Our PlanningEntity for PlanningProblem</entityClass>


    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

    public class CloudBalance extends AbstractPersistable {
        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 


    public class DinnerParty extends AbstractPersistable {
        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 


    public class TaskAssigningSolution extends AbstractPersistable {
        @ValueRangeProvider(id = "taskRange")
        private List<Task> taskList;


Tags: Java

Mobile Applications

Video Content

Bigdata & NoSQL

SaaS Applications



Alexa Certified Site Stats for