Thanks for clarifying this, I totally agree that the Vehicle is a planning 
entity and it should be treated as such thought.

I will be happy to open a JIRA for this.
Can you point me to instructions or do/don’t do list so I will do it properly?

Can you please clarify another thing regarding changes to entities in a 
ProblemFactChange code:
When a fact is changed, you call ScoreDirector.beforeProblemFactChanged and 
ScoreDirector.afterProblemFactChange on the fact object, regardless of the 
change specifics.
However, there is no such equivalent for entities.
My understanding is that you have to call ScoreDirector.beforeVariableChanged 
and ScoreDirector.afterVariableChange for every change, even for changes to 
none-panning variables
For example, when changing the Customer.demand or the Vehicle.capacity.

It becomes tricky when you need to change none planning variables that take 
part in calculating the actual solution. 
For example, changing the TimeWindowedCustomer.readyTime might result in 
constraint violation that is not reflected in the score (arrive before ready 
time) until the code in ArrivalTimeUpdatingVariableListener is invoked.

Can you please confirm or correct my understanding?

Thanks,
Hagai


On 6 May 2014, at 19:16, ge0ffrey [via Drools] 
<ml-node+s46999n4029440...@n3.nabble.com> wrote:

> Thanks for reporting. 
> 
> That's a terminology bug. 
> The Vehicle isn't both an entity and not an entity... 
> A) It's an entity because it has @PlanningVariable and a shadow variable. 
> B) But it's also not an entity because it doesn't have any genuine 
> variables, 
> and therefore ScoreDirector throws that NPE... (which should be a better 
> error message too). 
> I 'll fix this for 6.1, probably by discarding B). 
> 
> Could you file a jira for this? 
>    https://issues.jboss.org/browse/PLANNER
> 
> Workaround for 6.0.1: 
>     Presuming you're doing this in a ProblemFactChange, 
>     call scoreDirector.beforeProblemFactRemoved() instead of 
> beforeEntityRemoved() 
>     => Treat it as a problem fact for that... but treat is as an entity 
> for everything else. 
> 
> hth 
> 
> On 06-05-14 16:17, Hagai wrote:
> 
> > Using OptaPlanner 6.0.1.Final with problem like vehiclerouting. 
> > 
> > In vehiclerouting the Vehicle and Customer are both planning entities. They 
> > both implements the Standstill interface that is annotated with 
> > @PlanningEntity and their collections are annotated with 
> > @PlanningEntityCollectionProperty on the solution class. 
> > 
> > Flowing the code of VehicleRoutingPanel.insertLocationAndCustomer to insert 
> > a new Vehicle to the solution, my code is failing when the new Vehicle is 
> > reported to the score director: 
> > scoreDirector.beforeEntityAdded(newVehicle); 
> > 
> > The exception is NullPointerException at 
> > org.optaplanner.core.impl.domain.variable.listener.PlanningVariableListenerSupport.beforeEntityAdded(PlanningVariableListenerSupport.java:54)
> >  
> > 
> > It looks like the PlanningVariableListenerSupport.entityVariableListenerMap 
> > does not have item for the Vehicle entity, there is only one item for the 
> > Customer entity in this map. 
> > 
> > I get the same problem when calling ScoreDirector.beforeEntityRemoved to 
> > remove a Vehicle. 
> > 
> > Is this a bug or do I need to handle Vehicle entities differently? 
> > 
> > 
> > 
> > -- 
> > View this message in context: 
> > http://drools.46999.n3.nabble.com/NullPointerException-when-calling-ScoreDirector-beforeEntityAdded-with-new-Vehicle-tp4029434.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
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://drools.46999.n3.nabble.com/NullPointerException-when-calling-ScoreDirector-beforeEntityAdded-with-new-Vehicle-tp4029434p4029440.html
> To unsubscribe from NullPointerException when calling 
> ScoreDirector.beforeEntityAdded with new Vehicle, click here.
> NAML





--
View this message in context: 
http://drools.46999.n3.nabble.com/NullPointerException-when-calling-ScoreDirector-beforeEntityAdded-with-new-Vehicle-tp4029434p4029444.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to