aboutsummaryrefslogtreecommitdiff
path: root/utils/sddm/dc.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sddm/dc.py')
-rwxr-xr-xutils/sddm/dc.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/utils/sddm/dc.py b/utils/sddm/dc.py
index a1d87b5..d681831 100755
--- a/utils/sddm/dc.py
+++ b/utils/sddm/dc.py
@@ -343,12 +343,29 @@ class Constraint(object):
def renormalize(self, x, fix):
if fix not in self.range:
return x
+
+ if 1 - x[fix] < EPSILON:
+ return x
+
+ if self(x) < 0:
+ return x
+
+ # Scale all the other entries except for the fixed one by a constant to
+ # ensure that sum(x) = 1 - EPSILON
+ c = ((1-x[fix])-EPSILON)/sum(x[i] for i in self.range if i != fix)
+
x = x.copy()
+
+ for i in self.range:
+ if i != fix:
+ x[i] *= c
+
while self(x) >= 0:
for i in self.range:
if i == fix:
continue
- x[i] -= self(x)
+ x[i] /= 2
+
return x
def renormalize_no_fix(self, x):