Browse Source

修改限制逻辑

liuyuqi-dellpc 7 years ago
parent
commit
ee3f1af756
1 changed files with 11 additions and 5 deletions
  1. 11 5
      code/sort_by_disk.py

+ 11 - 5
code/sort_by_disk.py

@@ -77,14 +77,20 @@ def restrictApps(instance, deploy_list):
     else:
         ct = pd.Series(deploy_list).value_counts()
         for k, v in ct.items():
+            # tmp表示在df4中找到限制条件一行
             tmp = df4.loc[(df4["appid1"] == k) & (df4["appid2"] == instance)]
             row, col = tmp.shape
-            if row > 0:
-                if ct[instance] + 1 > tmp["max_interference"]:
-                    return False
+            if k == instance:
+                # a a 2 表示有一个a前提,还可以放2个a,最多可以放3个a
+                if row > 0:
+                    if ct[instance] > tmp["max_interference"]:
+                        return False
             else:
-                # 在限制表中找不到限制条件
-                return True
+                # a b 2 表示有一个a前提,还可以放2个b,最多可以放2个b
+                if row > 0:
+                    if ct[instance] + 1 > tmp["max_interference"]:
+                        return False
+        return True
 
 
 # 执行部署方案