<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <br>
    <br>
    Op 19-12-11 15:04, Patrik Dufresne schreef:
    <blockquote
cite="mid:CAJ=kj5yzXU0gJ=nCeMP8G+MK7mYkBqEJ99F_pDSCBK-_3Z0c1g@mail.gmail.com"
      type="cite">Hi Geoffrey,
      <div><br>
      </div>
      <div>Thanks for your opinion. I will try to implement what I call
        a <span style="color: rgb(51, 51, 51); font-family: 'Lucida
          Grande',Geneva,Verdana,Arial,sans-serif; font-size: 12px;
          line-height: 18px; text-align: justify;">HardAndSoftPriorityScoreDefini</span><span
          style="color: rgb(51, 51, 51); font-family: 'Lucida
          Grande',Geneva,Verdana,Arial,sans-serif; font-size: 12px;
          line-height: 18px; text-align: justify;">tion and give it back
          to the community. Where is the best place to post a 'patch' ?</span><br>
      </div>
    </blockquote>
    Create a pull request :) on <a class="moz-txt-link-freetext" href="http://github.com/drools-planner">http://github.com/drools-planner</a><br>
     
<a class="moz-txt-link-freetext" href="https://github.com/droolsjbpm/droolsjbpm-build-bootstrap/blob/master/README.md">https://github.com/droolsjbpm/droolsjbpm-build-bootstrap/blob/master/README.md</a><br>
    <br>
    Design wise, I recommend:<br>
    It's basically about allowing a dynamic number of levels, instead of
    just 2 (hard and soft).<br>
    it should not extend AbstractHardAndSoftScore, just extend
    AbstractScore<br>
    Because it cannot correctly implement
    HardAndSoftScore.getSoftScore();<br>
    I should just have a Map&lt;Integer, Integer&gt; levelToScoreMap;
    (no int hardScore or int softScore)<br>
    hardScore is like level 0.<br>
    softScore is like level -1.<br>
    This allows for:<br>
    softerScore at level -2<br>
    harderScore at level 1<br>
    Higher level is more important then lower level.<br>
    The class name should probably contain the word "Level".<br>
    <blockquote
cite="mid:CAJ=kj5yzXU0gJ=nCeMP8G+MK7mYkBqEJ99F_pDSCBK-_3Z0c1g@mail.gmail.com"
      type="cite">
      <div>
        <br>
        <div class="gmail_quote">2011/12/19 Geoffrey De Smet <span
            dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>&gt;</span><br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            <div text="#000000" bgcolor="#ffffff"> <br>
              <br>
              Op 14-12-11 18:40, Patrik Dufresne schreef:
              <blockquote type="cite">
                <div style="text-align: justify;">
                  <div>
                    <div>
                      <div style="font-size: 12px; line-height: 18px;"><font
                          color="#333333" face="'Lucida Grande', Geneva,
                          Verdana, Arial, sans-serif">
                          <div>Hi,</div>
                          <div><br>
                          </div>
                          <div>I'm still in process to model my planning
                            problem and I have some difficulties in
                            defining the correct weight of soft
                            constraints. I have soft constraints with
                            different priorities : C1, C2, C3, ..., Cn
                            where C1 are higher then C2. Currently, I've
                            tried to set different weight for each of
                            them : C1 get higher weight. But it's not
                            sufficient since multiple C2 may balance one
                            C1. What I really need is to set the
                            priority to every soft constraints.</div>
                          <div><br>
                          </div>
                          <div>Solution #1 :</div>
                          <div>My first thought it to implement a new
                            score definition
                            (HardAndSoftPriorityScoreDefinition) having
                            separate soft score for each priority. The
                            rule may insert ConstraintOccurence by
                            defining the weight and the priority. This
                            solution seems elegant but require effort to
                            implement the score definition, the score
                            calculation, and other things I don't even
                            know about.</div>
                        </font></div>
                    </div>
                  </div>
                </div>
              </blockquote>
              That is the perfect solution to your problem. Start by
              copy pasting <font><font color="#333333" face="'Lucida
                  Grande', Geneva, Verdana, Arial, sans-serif">DefaultHardAndSoftScoreDefinition
                  and work your way from there.<br>
                  You'll need to create at least a ScoreDefinition,
                  ScoreCalculator and Score.<br>
                  <br>
                  I've been thinking about adding such a "dynamic" score
                  definition to planner's build-in scores,<br>
                  but so far every use case where the developers said
                  they needed this, it turned out end-users meant it
                  differently:<br>
                  when you break a 100 C2's, then it's better to break 1
                  C1 instead...<br>
                </font></font>
              <blockquote type="cite">
                <div style="text-align: justify;">
                  <div>
                    <div>
                      <div style="font-size: 12px; line-height: 18px;"><font
                          color="#333333" face="'Lucida Grande', Geneva,
                          Verdana, Arial, sans-serif">
                          <div><br>
                          </div>
                          <div>Solution #2 :</div>
                          <div>The other solution is stated in the
                            Drools Planner User Guide : </div>
                        </font></div>
                    </div>
                  </div>
                </div>
                <blockquote style="margin: 0pt 0pt 0pt 40px; border:
                  medium none; padding: 0px;">
                  <div style="text-align: justify;">
                    <div>
                      <div>
                        <div style="font-size: 12px; line-height: 18px;"><font
                            color="#333333" face="'Lucida Grande',
                            Geneva, Verdana, Arial, sans-serif">
                            <div>"Most use cases will also weigh their
                              constraints differently, by multiplying
                              the count of each score rule with its
                              weight. For example in freight routing,
                              you can make 5 broken "avoid crossroads"
                              soft constraints count as much as 1 broken
                              "avoid highways at rush hour" soft
                              constraint. This allows your business
                              analysts to easily tweak the score
                              function as they see fit."</div>
                          </font></div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                <div style="text-align: justify;">
                  <div>
                    <div>
                      <div><font color="#333333" face="'Lucida Grande',
                          Geneva, Verdana, Arial, sans-serif">
                          <div style="font-size: 12px; line-height:
                            18px;"> Even tough I don't know how to
                            implement this, it's seems much easier to
                            achieve since it's only a rule. Compare to
                            solution #1, it's lack the support of soft
                            constraints with same priority but different
                            weights.</div>
                        </font></div>
                    </div>
                  </div>
                </div>
              </blockquote>
              That text describes plain-old weighting. Say C1 weights
              100 and C2 weights 2, then you can break 50 C2's for every
              1 broken C1.<br>
              <br>
              This is far easier and most of the time end-users actually
              mean this.<br>
              Make exaggerated examples (1000 C2's broken vs 1 C1
              broken) and make your end-users decide what they prefer.
              If they still prefer 1000 C2's broken, then you need #1.<br>
              <br>
              Tip: Sometimes, taking the square of a weight is a neat
              trick.<br>
              In bin packing, say you got<br>
              Solution A with 3 CPU and 3 CPU too little = 3² + 3² = 18<br>
              and Solution B with 4 CPU and 2 CPU too little = 4² + 2² =
              20<br>
              So the second is worse even though they both miss 6 CPU.<br>
              <br>
              <blockquote type="cite">
                <div style="text-align: justify;">
                  <div>
                    <div>
                      <div><font color="#333333" face="'Lucida Grande',
                          Geneva, Verdana, Arial, sans-serif">
                          <div style="font-size: 12px; line-height:
                            18px;"><br>
                          </div>
                          <div style="font-size: 12px; line-height:
                            18px;">What is your opinion about both
                            solution.</div>
                          <div style="font-size: 12px; line-height:
                            18px;"><br>
                          </div>
                          <div style="font-size: 12px; line-height:
                            18px;"> Is one faster then the other ? </div>
                          <div style="font-size: 12px; line-height:
                            18px;"><br>
                          </div>
                          <div><span style="font-size: 12px;
                              line-height: 18px;">Is it hard to create a
                              new score definition ?</span></div>
                          <div><span style="font-size: 12px;
                              line-height: 18px;"><br>
                            </span></div>
                          <div><span style="font-size: 12px;
                              line-height: 18px;">Did anyone ever did
                              this ? </span></div>
                          <span class="HOEnZb"><font color="#888888">
                              <div style="font-size: 12px; line-height:
                                18px;"><br>
                              </div>
                            </font></span></font></div>
                      <span class="HOEnZb"><font color="#888888"> </font></span></div>
                    <span class="HOEnZb"><font color="#888888"> </font></span></div>
                  <span class="HOEnZb"><font color="#888888"> </font></span></div>
                <span class="HOEnZb"><font color="#888888"> -- <br>
                    Patrik Dufresne<br>
                    <pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
                  </font></span></blockquote>
              <span class="HOEnZb"><font color="#888888"> <br>
                  <pre cols="72">-- 
With kind regards,
Geoffrey De Smet</pre>
                </font></span></div>
            <br>
            _______________________________________________<br>
            rules-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.jboss.org/mailman/listinfo/rules-users"
              target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        Patrik Dufresne<br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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>
    <pre class="moz-signature" cols="72">-- 
With kind regards,
Geoffrey De Smet</pre>
  </body>
</html>