Quantcast

Planner - Initialized solution & local search

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Planner - Initialized solution & local search

Garf
I'm using v5.4. I've built a prototype which uses the constructionHeuristic, and localSearch, as the example does, and am able to run the solver (though it still doesn't do a good job of solving at this point).

I've now added customSolverPhase, and set it to use an initializer class which implements CustomSolverPhaseCommand.

In my changeWorkingSolution, I call scoreDirector.beforeEntityAdded(), and then set the planning entity's planning variable, and then call afterEntityAdded().

If I leave any entities unadded -- and let the constructionHeuristic (BEST_FIT, etc) do the fitting (which I can verify from the logs)-- I then get this exception:

java.lang.IllegalStateException: Phase localSearch started with an uninitialized Solution. First initialize the Solution. For example, run a phase constructionHeuristic first.

For now, I can update my code to ensure that all of the entities are fitted and bypass the constructionHeuristic, but I'm curious why this error is getting thrown. I did hunt through the source code to look at all the isInitialized() methods, but I haven't yet stepped through to see which one returns false any why.

As for turning on TRACE mode, see my recent post.

Jon
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] Planner - Initialized solution & local search

ge0ffrey
Administrator



Op 11-07-12 17:19, Garf schreef:

> I'm using v5.4. I've built a prototype which uses the constructionHeuristic,
> and localSearch, as the example does, and am able to run the solver (though
> it still doesn't do a good job of solving at this point).
>
> I've now added customSolverPhase, and set it to use an initializer class
> which implements CustomSolverPhaseCommand.
>
> In my changeWorkingSolution, I call scoreDirector.beforeEntityAdded(), and
> then set the planning entity's planning variable, and then call
> afterEntityAdded().
>
> If I leave any entities unadded -- and let the constructionHeuristic
> (BEST_FIT, etc) do the fitting (which I can verify from the logs)-- I then
> get this exception:
>
> /java.lang.IllegalStateException: Phase localSearch started with an
> uninitialized Solution. First initialize the Solution. For example, run a
> phase constructionHeuristic first./
This sounds like a bug.
Unless, you called afterEntityAdded() on the non initialized entities too?

If that's not the case, could you file a jira?
   https://issues.jboss.org/browse/JBRULES

> For now, I can update my code to ensure that all of the entities are fitted
> and bypass the constructionHeuristic, but I'm curious why this error is
> getting thrown. I did hunt through the source code to look at all the
> isInitialized() methods, but I haven't yet stepped through to see which one
> returns false any why.
>
> As for turning on TRACE mode, see my
> http://drools.46999.n3.nabble.com/drools-planner-5-4-0-Final-java-lang-IllegalStateException-Score-corruption-the-workingScore-tp3981199p4018558.html
> recent post .
>
> Jon
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Planner-Initialized-solution-local-search-tp4018594.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
>

--
With kind regards,
Geoffrey De Smet


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

Re: [rules-users] Planner - Initialized solution & local search

ge0ffrey
Administrator


Op 11-07-12 17:52, Geoffrey De Smet schreef:

>
>
> Op 11-07-12 17:19, Garf schreef:
>> I'm using v5.4. I've built a prototype which uses the constructionHeuristic,
>> and localSearch, as the example does, and am able to run the solver (though
>> it still doesn't do a good job of solving at this point).
>>
>> I've now added customSolverPhase, and set it to use an initializer class
>> which implements CustomSolverPhaseCommand.
>>
>> In my changeWorkingSolution, I call scoreDirector.beforeEntityAdded(), and
>> then set the planning entity's planning variable, and then call
>> afterEntityAdded().
>>
>> If I leave any entities unadded -- and let the constructionHeuristic
>> (BEST_FIT, etc) do the fitting (which I can verify from the logs)-- I then
>> get this exception:
>>
>> /java.lang.IllegalStateException: Phase localSearch started with an
>> uninitialized Solution. First initialize the Solution. For example, run a
>> phase constructionHeuristic first./
> This sounds like a bug.
> Unless, you called afterEntityAdded() on the non initialized entities too?
>
> If that's not the case, could you file a jira?
>     https://issues.jboss.org/browse/JBRULES
It's strange though: partially initialized solutions work fine in
real-time planning use cases in cloud balance example etc.
Double check if you aren't calling afterEntityAdded() on the
non-initialized entities too.
Also check that the construction heurstics run before the localSearch
solver does (the order in which they are declared in the config xml
matters).

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

Re: [rules-users] Planner - Initialized solution & local search

Garf
re: Double check if you aren't calling afterEntityAdded() on the non-initialized entities too. Also check that the construction heurstics run before the localSearch solver does (the order in which they are declared in the config xml matters). Checked both. I'll file a JIRA bug, but I'm just searching the source some more -- I'm trying to verify that DefaultGreedyFitSolverPhase.solve() doesn't exit the loop before calling setSolutionInitialized(). Jon
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] Planner - Initialized solution & local search

ge0ffrey
Administrator


Op 11-07-12 21:56, Garf schreef:
re: Double check if you aren't calling afterEntityAdded() on the non-initialized entities too. Also check that the construction heurstics run before the localSearch solver does (the order in which they are declared in the config xml matters). Checked both. I'll file a JIRA bug, but I'm just searching the source some more -- I'm trying to verify that DefaultGreedyFitSolverPhase.solve() doesn't exit the loop before calling setSolutionInitialized(). Jon
Thanks,

Alternatively, you can also try reproducing it on the pas example, by
only partially initializing the solution in PatientAdmissionScheduleSolutionInitializer
and adding a <constructionHeuristic> in patientAdmissionScheduleSolverConfig.xml
If you can reproduce it there, I 'll fix it tomorrow on master and backport it to 5.4.x (no immediate release planned).

View this message in context: Re: [rules-users] Planner - Initialized solution & local search
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

-- 
With kind regards,
Geoffrey De Smet

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

Re: [rules-users] Planner - Initialized solution & local search

Garf
I figured out the problem.

DefaultSolver.runSolverPhases() will go through each phase, and will revert the changes if they're not better. Or, more exactly, here are lines 191-193:

            if (it.hasNext()) {
                // solverScope.setWorkingSolutionFromBestSolution();
            }

Now, if this involved setting the planning variables for the first time, those will be reverted.

There's a few ways of tackling this, some of which are on the user end, such as a adding a hard constraint to penalize the solution if the planning variable isn't set.

Jon
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] Planner - Initialized solution & local search

ge0ffrey
Administrator
That's a bug, issue created:
   https://issues.jboss.org/browse/JBRULES-3577
It needs to be fixed on an architectural level though.

Op 13-07-12 01:46, Garf schreef:

> DefaultSolver.runSolverPhases() will go through each phase, and will revert
> the changes if they're not better. Or, more exactly, here are lines 191-193:
>
>              if (it.hasNext()) {
>                  // solverScope.setWorkingSolutionFromBestSolution();
>              }
>
> Now, if this involved setting the planning variables for the first time,
> those will be reverted.
>
> There's a few ways of tackling this, some of which are on the user end, such
> as a adding a hard constraint to penalize the solution if the planning
> variable isn't set.
>
> Jon
>
> --
> View this message in context:http://drools.46999.n3.nabble.com/Planner-Initialized-solution-local-search-tp4018594p4018642.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.

--
With kind regards,
Geoffrey De Smet


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Loading...