浏览代码

supply: allow limiting factor to shift each iteration

raylu 3 周之前
父节点
当前提交
819a81cfdd
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 4 7
      supply.py

+ 4 - 7
supply.py

@@ -36,13 +36,9 @@ def main() -> None:
 
 	print(f'consuming {vol_per_day:.1f}㎥/d')
 	print(f'consuming {weight_per_day:.1f}t/d')
-	limiting = 'Volume'
-	if weight_per_day > vol_per_day:
-		limiting = 'Weight'
-
 	target_days = round(target_days + 0.05, 1)
 	while True:
-		space_used = 0
+		weight_used = volume_used = 0
 		buy: dict[str, float] = {}
 		for consumption in net_consumption:
 			ticker = consumption['MaterialTicker']
@@ -51,9 +47,10 @@ def main() -> None:
 			days = avail / daily_consumption
 			if days < target_days:
 				buy[ticker] = (target_days - days) * daily_consumption
-				space_used += buy[ticker] * materials[ticker][limiting]
+				weight_used += buy[ticker] * materials[ticker]['Weight']
+				volume_used += buy[ticker] * materials[ticker]['Volume']
 
-		if space_used > 500:
+		if weight_used > 500 or volume_used > 500:
 			break
 		optimal = buy
 		target_days += 0.1