<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt">Hi,<br><br>I need to group a number of entities together and I'm not sure if my rule is optimal.<br><br>My planning entities represent maintenance tasks on airplanes.<br>Every planning entity is a discreet task (check tires, refuel, check engines...) but the maintenance of an airplane exists of a number of these tasks and they need to be grouped together.<br>Every task has a duration depending on its type (checking engine takes longer than checking tires).<br>The optimal solution is that all tasks of a maintenance are in the smallest amount of time (time between start of first task till end of last task).<br>Though, the smaller the better, at least all tasks should be sequential (without gaps between the tasks).<br>Dependencies on the tasks are availability of the plain, availability of the technicians...<br><br>(The rules beneath only
check that the tasks are chained together, not (yet) that the time span is minimal => I thought to make a soft-constraint for that).<br><br>First I had this rule:<br><br>rule "tasksInSameMaintenanceJobMustBeChained"<br> when<br> $task : Task( $jobId: jobId )<br> not ( Task( jobId== $jobId, id != $task.id, ($task.startPeriodId-1) <= endPeriodId && ($task.endPeriodId+1) >= startPeriodId ) )<br> then // we have a gap!<br> insertLogical(new IntConstraintOccurrence("tasksInSameMaintenanceJobMustBeChained", ConstraintType.NEGATIVE_HARD, Importance.chainedPeriod, $jobId, $task));<br>end<br><div><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>After adding
this rule I started struggling with what I believe is to be a score trap.</span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>After advice from Geoffrey and reading some more, I thought my rule suffered from having a penalty which did not change depending on the amount of spread of the tasks.</span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>So I rewrote the task to:</span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">(I have now put all
<span>MaintenanceJobs into the working memory and I created a Class TaskSet() which is capable of calculating the nr of periods between all tasks of a job = gapCount)</span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span></span><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>rule "</span><span>tasksInSameMaintenanceJobMustBeChained"<br> when<br> $job: MaintenanceJob()<br> $taskset : TaskSet( gapCount > 0 )<br> from accumulate( $task : Task(jobId== $job.id),<br>
init( TaskSet taskset = new TaskSet(); ),<br> action( taskset.addTask( $task ); ),<br> reverse( taskset.removeTask( $task ); ),<br> result( taskset ) );<br> then<br> insertLogical(new IntConstraintOccurrence("</span><span><span></span><span>tasksInSameMaintenanceJobMustBeChained</span>",
ConstraintType.NEGATIVE_HARD, </span><span>Importance.chainedPeriod * $taskset.getGapCount(), $job, $taskset));<br>end<br></span></div><div> <br>I see a difference in score but still not optimal and terminated on time limit reached.<br><br><span style="text-decoration: underline;"><span>1) Is this rule as good as it can be? Or am I creating some issue here?</span></span><br><br>A Task (planning entity) has 3 different planning variables.<br><span style="text-decoration: underline;">2) When I analyze the Trace logging I see that during the first steps the 3 variables are switched during moves, but then after a while only one of the 3 variables gets changed and the other variables of all tasks remain as they are.</span><br><br>Should I conclude something out of that?<br><br>This is my local search config:<br><br> <localSearch><br> <termination><br>
<terminationCompositionStyle>OR</terminationCompositionStyle><br> <maximumSecondsSpend>3600</maximumSecondsSpend><br> <scoreAttained>0hard/0soft</scoreAttained><br> </termination><br> <unionMoveSelector><br> <changeMoveSelector><br> <valueSelector><br> <!-- ** --><br>
<planningVariableName>role</planningVariableName><br> </valueSelector><br> </changeMoveSelector><br> <changeMoveSelector><br> <valueSelector><br> <!-- entity var technician:who will execute the task --><br> <planningVariableName>technician</planningVariableName><br> </valueSelector><br>
</changeMoveSelector><br> <changeMoveSelector><br> <valueSelector><br> <!-- entity var period: when will the plane get maintenance --><br> <planningVariableName>period</planningVariableName><br> </valueSelector><br> </changeMoveSelector><br> <swapMoveSelector><br> </swapMoveSelector><br>
</unionMoveSelector><br><br> <acceptor><br> <!-- 3 => small amount of planning entities in unit test --><br> <planningEntityTabuSize>3</planningEntityTabuSize><br> </acceptor><br> <forager><br> <minimalAcceptedSelection>1000</minimalAcceptedSelection><br> </forager><br> </localSearch><br><br>(**) entity var role: every maintenance job has one lead task (role == lead),
all other tasks in that job must have role = member. The technician
assigned to the lead task will file the maintenance report.<br>One of the constraints (checked in other rule) is that no technician should be lead-technician twice in a row on two sequential maintenance jobs.<br><br>Thanks in advance.<br><br>Michiel<br></div><div>-----------------<br>http://www.codessentials.com - Your essential software, for free!<br>Follow us at http://twitter.com/#!/Codessentials</div></div></body></html>