<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Does the pas (patient admission scheduling AKA hospital bed
    planning) example behave similar as you need it?<br>
    One pas night = 30 minutes for you. One pas admission (several
    nights) = 1 job (several times 30 minutes).<br>
    <br>
    <div class="moz-cite-prefix">Op 13-12-12 16:16, mr_moe schreef:<br>
    </div>
    <blockquote cite="mid:1355411790135-4021192.post@n3.nabble.com"
      type="cite">Hey,
      I want to solve the following problem using drools planner:<br>
      There are several jobs which should be worked through by a machine
      on one day. Each job has a length and a constraint that it only
      can be worked of between a fixed start and end date.
      For example there are three tasks
      <table>
        <tbody>
          <tr>
            <td>Job</td>
            <td>first possible start date</td>
            <td>last possible start date</td>
            <td>length</td>
          </tr>
          <tr>
            <td>A</td>
            <td>7:00 am</td>
            <td>8:30 am</td>
            <td>60 min</td>
          </tr>
          <tr>
            <td>B</td>
            <td>7:30 am</td>
            <td>10:00 am</td>
            <td>30 min</td>
          </tr>
          <tr>
            <td>C</td>
            <td>10:30 am</td>
            <td>12:00 pm</td>
            <td>60 min</td>
          </tr>
        </tbody>
      </table>
      The jobs should be organized in the following way, that there is
      as less time between tasks as possible. If it is due to
      restrictions not possible to order the tasks without a break and
      also the break is longer than, say, 20 minutes, the tasks should
      be organized with a long break as possible.<br>
      Tasks cannot overlap.
      A good solution would be:
      <table>
        <tbody>
          <tr>
            <td>Job</td>
            <td>Start date</td>
            <td>End date</td>
          </tr>
          <tr>
            <td>A</td>
            <td>7:00 am</td>
            <td>8:00 am</td>
          </tr>
          <tr>
            <td>B</td>
            <td>8:00 am</td>
            <td>8:30 am</td>
          </tr>
          <tr>
            <td>C</td>
            <td>12:00 am</td>
            <td>1:00 pm</td>
          </tr>
        </tbody>
      </table>
      First, the planning variable
      (ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY) of each task is its
      start date, which can takes a value which is between the first
      possible start date and the last possible start date. E.g.
      possible start dates for job A are between 7:00 am and 8:30 am. <br>
      To make sure, that tasks aren&#8217;t scheduled at the same time, I&#8217;ve
      written a hard constraint rule, which checks if one task overlaps
      with another one. And running the planner with hard constraints
      only, it works fine.
      But now I&#8217;m getting problems, writing the soft constraints. <br>
      At the moment, every job (planning entity) has variables, called
      &#8220;nextJob&#8221; und &#8220;prevJob&#8221;, which points to the jobs which are
      scheduled before and after that job. <br>
      In my example, it would look like this:
      <table>
        <tbody>
          <tr>
            <td>Job</td>
            <td>prevJob</td>
            <td>nextJob</td>
          </tr>
          <tr>
            <td>A</td>
            <td>null</td>
            <td>Job B</td>
          </tr>
          <tr>
            <td>B</td>
            <td>Job A</td>
            <td>Job C</td>
          </tr>
          <tr>
            <td>C</td>
            <td>Job B</td>
            <td>null</td>
          </tr>
        </tbody>
      </table>
      My intention of these variables is that I can check with a soft
      constraint rule, if the current chosen job and the job with which
      it gets compared are consecutive jobs, and if so, how much time
      between these jobs is left.
      In the soft constraint rule, I check if the &#8220;nextJob&#8221; Variable
      points to the job, with which I&#8217;m currently comparing the job. If
      this is the case, then there is no other job scheduled between
      those jobs and I can check how much time between these jobs is
      left.
      Every time drools planner reschedules a job, I have to check if
      nextJob and prevJob of each job are still pointing to their right
      predecessor and successor.
      For example, if Job A gets moved to 8:00 the sequence could look
      like this:
      <table>
        <tbody>
          <tr>
            <td>Job</td>
            <td>Start date</td>
            <td>End date</td>
          </tr>
          <tr>
            <td>A</td>
            <td>8:00 am</td>
            <td>9:00 am</td>
          </tr>
          <tr>
            <td>B</td>
            <td>7:30 am</td>
            <td>8:00 am</td>
          </tr>
          <tr>
            <td>C</td>
            <td>12:00 am</td>
            <td>1:00 pm</td>
          </tr>
        </tbody>
      </table>
      Therefore the variables preJob and nextJob have to be adjusted for
      each job:
      <table>
        <tbody>
          <tr>
            <td>Job</td>
            <td>prevJob</td>
            <td>nextJob</td>
          </tr>
          <tr>
            <td>Job A</td>
            <td>Job B</td>
            <td>Job C</td>
          </tr>
          <tr>
            <td>Job B</td>
            <td>null</td>
            <td>Job A</td>
          </tr>
          <tr>
            <td>Job C</td>
            <td>Job A</td>
            <td>null</td>
          </tr>
        </tbody>
      </table>
      To achieve that, I use a list in which I save the current order of
      the jobs.<br>
      Furthermore I&#8217;ve written my own mover that, besides assigning the
      current job to its new start date, updates the list and each job
      if a job gets rescheduled.
      You&#8217;ve probably got the punch line by now: It&#8217;s not working. <br>
      And besides from getting a scoreCurroption exception, I truly
      doubt that this is the perfect solution for solving this planning
      problem.<br>
      Have any of you an idea, what a better way for solving this
      problem could be?
      I&#8217;ve tried to find a similar problem in the examples, but none of
      them has similar restrictions as mine. <br>
      The curriculumcourse example has only fixed time slots instead of
      a variable length and in the nurserostering, nurses (jobs) get
      assigned to fixed shifts (time periods) and not the other way
      around. Thanks! <br>
      <hr align="left" width="300">
      View this message in context: <a moz-do-not-send="true"
href="http://drools.46999.n3.nabble.com/Drools-Planner-Solving-a-job-schedule-problem-tp4021192.html">Drools
        Planner: Solving a job schedule problem</a><br>
      Sent from the <a moz-do-not-send="true"
        href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools:
        User forum mailing list archive</a> at Nabble.com.<br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>