[rules-users] Drools Planner: Planning variable gets assigned value out of valueRange

mr_moe mc_entry at web.de
Tue Nov 27 08:16:25 EST 2012


Hey,

I have a planning entity, which has one planning variable called startDate.
This variable has a defined discrete value range which is a list of numbers
of the type long. Every number represents a timestamp, which is in between
the number firstPossibleStartDate and lastPossibleStartDate.

During the planning process, the number 0 is sometimes assigned to the
planning variable which is definitely not part of the valueRange. I’ve
printed the list to the console, but all values in the list are fine.

Because every planning entity has its own valueRange, the range is defined
in the entity itself.

At the moment I’ve implemented my own mover, but the problem occurs also
with pre-configured mover.

During my research I’ve stumbled upon the following note in the Planner
Documentation: 
ValueRange from planning entity is currently not yet supported by the new
MoveSelectors.
Does this has something to do with my problem?

Enclosed you will find the code of the planning entity.

@PlanningEntity
public class DroolTask {
	private List<Long> startDateList;
	private int id;
	private String name;
	private long duration;
	private long firstPossibleStartDate;
	private long lastPossibleStartDate;
	private String nextTask = "";
	private String previousTask = "";
	
	// Planning variables: changes during planning, between score calculations.
	private long startDate;
	
	@PlanningVariable
	@ValueRange(type = ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY,
planningEntityProperty = "startDateList")
	public long getStartDate(){
		return startDate;
	}
	
	public void setStartDate(long startDate){
		this.startDate = startDate;
	}
	
	
	public List<Long> getStartDateList(){
		return this.startDateList;
	}
	
	public void setStartDateList(){
		startDateList = getPossibleStartDate();
	}
	
	public List<Long> getPossibleStartDate(){
		startDateList = new ArrayList<Long>();
		for(long i = firstPossibleStartDate; i<=lastPossibleStartDate; i = i +
60){
			startDateList.add(i);
		}
		return startDateList;
	}
	
	public Long getFirstPossibleStartDate(){
		return firstPossibleStartDate;
	}
	
	public void setFirstPossibleStartDate(long firstPossibleStartDate){
		this.firstPossibleStartDate = firstPossibleStartDate;
	}
	
	public Long getLastPossibleStartDate(){
		return lastPossibleStartDate;
	}
	
	public void setLastPossibleStartDate(long lastPossibleEndDate){
		this.lastPossibleStartDate = lastPossibleEndDate;
	}
	
[...]

	
	public DroolTask clone(){
		DroolTask clone = new DroolTask();
		
		clone.name = name;
		clone.duration = duration;
		clone.firstPossibleStartDate = firstPossibleStartDate;
		clone.lastPossibleStartDate = lastPossibleStartDate;
		clone.startDate = startDate;
		clone.nextTask = nextTask;
		clone.previousTask = previousTask;
		clone.startDateList = startDateList;
		
		return clone;
	}

[...]
}

It would be great, if someone could give me a hint.
Many thanks,

Moe



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-Planning-variable-gets-assigned-value-out-of-valueRange-tp4020984.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list