[haiku-commits] r40940 - haiku/trunk/src/libs/linprog

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 14 Mar 2011 01:17:30 +0100 (CET)

Author: czeidler
Date: 2011-03-14 01:17:30 +0100 (Mon, 14 Mar 2011)
New Revision: 40940
Changeset: http://dev.haiku-os.org/changeset/40940

Modified:
   haiku/trunk/src/libs/linprog/LayoutOptimizer.cpp
Log:
Soft constraints can now be weighted.



Modified: haiku/trunk/src/libs/linprog/LayoutOptimizer.cpp
===================================================================
--- haiku/trunk/src/libs/linprog/LayoutOptimizer.cpp    2011-03-14 00:06:23 UTC 
(rev 40939)
+++ haiku/trunk/src/libs/linprog/LayoutOptimizer.cpp    2011-03-14 00:17:30 UTC 
(rev 40940)
@@ -538,7 +538,17 @@
                        rightSide[c] = 0;
                        continue;
                }
-               rightSide[c] = _RightSide(constraint);
+               double weight = 0;
+               double negPenalty = constraint->PenaltyNeg();
+               if (negPenalty > 0)
+                       weight += negPenalty;
+               double posPenalty = constraint->PenaltyPos();
+               if (posPenalty > 0)
+                       weight += posPenalty;
+               if (negPenalty > 0 && posPenalty > 0)
+                       weight /= 2;
+               
+               rightSide[c] = _RightSide(constraint) * weight;
                SummandList* summands = constraint->LeftSide();
                for (int32 s = 0; s < summands->CountItems(); s++) {
                        Summand* summand = summands->ItemAt(s);
@@ -547,6 +557,7 @@
                                fSoftConstraints[c][variable] = 
-summand->Coeff();
                        else
                                fSoftConstraints[c][variable] = 
summand->Coeff();
+                       fSoftConstraints[c][variable] *= weight;
                }
        }
 


Other related posts:

  • » [haiku-commits] r40940 - haiku/trunk/src/libs/linprog - clemens . zeidler