Starting optaplanner with your own initialized solution

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting optaplanner with your own initialized solution

paavanm
I have a relatively simple question. How do I have OptaPlanner use my own initialized solution as a starting point instead of having a construction heuristic create one? Does this have to be done with a custom SolverPhase?

A little more detail on what I'm trying to do: I am scheduling a series of classes and related activities on a calendar. Let's say I have some class BA101 that occurs several times a week (these classes are immovable entities). There are homeworks, exams etc. associated with these classes which I need to schedule. E.g. on Feb 1st, a homework might be due, or on Mar 1st, there might be an exam. So I need to schedule time to do the homework or time to study for the exam. My initial solution for this would be very simple: I would schedule the homework/study time at the same time of the class itself, and let optaplanner move it around till it meets my hard & soft constraints.

However, when I tried to do that (i.e. give my homework/study tasks an actual start time instead of just leaving the start time as null), OptaPlanner fell right through without actually making any moves to find the best score. How do I do this? This is my config at the moment, pretty basic (tried this with & without the construction heuristic; same result):

<?xml version="1.0" encoding="UTF-8"?>
<solver>

   
    <solutionClass>com.copilot.optaplanner.domain.ActivityScheduler</solutionClass>
    <planningEntityClass>com.copilot.optaplanner.domain.Activity</planningEntityClass>

   
    <scoreDirectorFactory>
        <scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
        <simpleScoreCalculatorClass>com.copilot.optaplanner.solver.score.ActivitySchedulingSimpleScoreCalculator</simpleScoreCalculatorClass>
    </scoreDirectorFactory>

   
    <termination>
        <maximumSecondsSpend>10</maximumSecondsSpend>
    </termination>

    <constructionHeuristic>
        <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
    </constructionHeuristic>

    <localSearch>
        <acceptor>
            <entityTabuSize>7</entityTabuSize>
        </acceptor>
        <forager>
            <acceptedCountLimit>1000</acceptedCountLimit>
        </forager>
    </localSearch>

</solver>

Thanks for any assistance.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Starting optaplanner with your own initialized solution

Mattias Nilsson Grip
Hi,

OptaPlanner should be able to start with your initialized solution and let localSearch attempt to optimize it. You should not need to have a custom solver phase for this.

Is your score calculation correct? What is the score of the solution when you run with actual start time populated vs when you leave start time as null?

If you turn on debug logging for package org.optaplanner you should get some more info on what goes on inside the solver.

Regards,
Mattias

----- Original Message -----

> From: "paavanm" <[hidden email]>
> To: [hidden email]
> Sent: Wednesday, 20 August, 2014 11:42:56 PM
> Subject: [rules-users] Starting optaplanner with your own initialized solution
>
> I have a relatively simple question. How do I have OptaPlanner use my own
> initialized solution as a starting point instead of having a construction
> heuristic create one? Does this have to be done with a custom SolverPhase?
>
> A little more detail on what I'm trying to do: I am scheduling a series of
> classes and related activities on a calendar. Let's say I have some class
> BA101 that occurs several times a week (these classes are immovable
> entities). There are homeworks, exams etc. associated with these classes
> which I need to schedule. E.g. on Feb 1st, a homework might be due, or on
> Mar 1st, there might be an exam. So I need to schedule time to do the
> homework or time to study for the exam. My initial solution for this would
> be very simple: I would schedule the homework/study time at the same time of
> the class itself, and let optaplanner move it around till it meets my hard &
> soft constraints.
>
> However, when I tried to do that (i.e. give my homework/study tasks an
> actual start time instead of just leaving the start time as null),
> OptaPlanner fell right through without actually making any moves to find the
> best score. How do I do this? This is my config at the moment, pretty basic
> (tried this with & without the construction heuristic; same result):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <solver>
>
>    
>    
> <solutionClass>com.copilot.optaplanner.domain.ActivityScheduler</solutionClass>
>    
> <planningEntityClass>com.copilot.optaplanner.domain.Activity</planningEntityClass>
>
>    
>     <scoreDirectorFactory>
>         <scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
>        
> <simpleScoreCalculatorClass>com.copilot.optaplanner.solver.score.ActivitySchedulingSimpleScoreCalculator</simpleScoreCalculatorClass>
>     </scoreDirectorFactory>
>
>    
>     <termination>
>         <maximumSecondsSpend>10</maximumSecondsSpend>
>     </termination>
>
>     <constructionHeuristic>
>         <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
>     </constructionHeuristic>
>
>     <localSearch>
>         <acceptor>
>             <entityTabuSize>7</entityTabuSize>
>         </acceptor>
>         <forager>
>             <acceptedCountLimit>1000</acceptedCountLimit>
>         </forager>
>     </localSearch>
>
> </solver>
>
> Thanks for any assistance.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Starting-optaplanner-with-your-own-initialized-solution-tp4030697.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

--
Mattias Nilsson Grip
Redpill Linpro AB - Changing the game
Tel: +46 734 09 22 34
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

[rules-users] Moved to google groups

Mark Proctor
In reply to this post by paavanm
OptaPlanner now has it’s own google groups for discussions:

Please use the correct group, to reduce the noise to signal ratio. 

Also just a reminder this list has also moved to Google Groups:

Mark


On 20 Aug 2014, at 22:42, paavanm <[hidden email]> wrote:

I have a relatively simple question. How do I have OptaPlanner use my own
initialized solution as a starting point instead of having a construction
heuristic create one? Does this have to be done with a custom SolverPhase?

A little more detail on what I'm trying to do: I am scheduling a series of
classes and related activities on a calendar. Let's say I have some class
BA101 that occurs several times a week (these classes are immovable
entities). There are homeworks, exams etc. associated with these classes
which I need to schedule. E.g. on Feb 1st, a homework might be due, or on
Mar 1st, there might be an exam. So I need to schedule time to do the
homework or time to study for the exam. My initial solution for this would
be very simple: I would schedule the homework/study time at the same time of
the class itself, and let optaplanner move it around till it meets my hard &
soft constraints.

However, when I tried to do that (i.e. give my homework/study tasks an
actual start time instead of just leaving the start time as null),
OptaPlanner fell right through without actually making any moves to find the
best score. How do I do this? This is my config at the moment, pretty basic
(tried this with & without the construction heuristic; same result):

<?xml version="1.0" encoding="UTF-8"?>
<solver>



<solutionClass>com.copilot.optaplanner.domain.ActivityScheduler</solutionClass>

<planningEntityClass>com.copilot.optaplanner.domain.Activity</planningEntityClass>


   <scoreDirectorFactory>
       <scoreDefinitionType>HARD_SOFT</scoreDefinitionType>

<simpleScoreCalculatorClass>com.copilot.optaplanner.solver.score.ActivitySchedulingSimpleScoreCalculator</simpleScoreCalculatorClass>
   </scoreDirectorFactory>


   <termination>
       <maximumSecondsSpend>10</maximumSecondsSpend>
   </termination>

   <constructionHeuristic>
       <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
   </constructionHeuristic>

   <localSearch>
       <acceptor>
           <entityTabuSize>7</entityTabuSize>
       </acceptor>
       <forager>
           <acceptedCountLimit>1000</acceptedCountLimit>
       </forager>
   </localSearch>

</solver>

Thanks for any assistance.



--
View this message in context: http://drools.46999.n3.nabble.com/Starting-optaplanner-with-your-own-initialized-solution-tp4030697.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Starting optaplanner with your own initialized solution

paavanm
In reply to this post by Mattias Nilsson Grip
Thanks, actually after checking my score calculation, I realized I had introduced a bug in my code. I had set all my planning entities to immovable entities. Fixed that and it works fine, thanks again.