Commit
·
275ca2d
1
Parent(s):
ea992b5
Update app.py
Browse files
app.py
CHANGED
@@ -94,13 +94,16 @@ def calculator(*args):
|
|
94 |
and inventory constraints.
|
95 |
|
96 |
Args:
|
97 |
-
*args (tuple): A tuple
|
98 |
-
|
99 |
-
|
|
|
|
|
100 |
|
101 |
Returns:
|
102 |
str: A description of the optimal solution, including which plants to sell,
|
103 |
the total gold earned, and the remaining inventory.
|
|
|
104 |
"""
|
105 |
budget: int = args[0] # 葭碧预算
|
106 |
strategy: str = args[1] # 出售策略
|
@@ -142,7 +145,7 @@ def calculator(*args):
|
|
142 |
|
143 |
# 求解问题
|
144 |
# CBC(Coin-or Branch and Cut)求解器使用分支定界算法来寻找整数规划问题的最优解
|
145 |
-
solver = pulp.
|
146 |
prob.solve(solver=solver)
|
147 |
|
148 |
if pulp.LpStatus[prob.status] == "Optimal":
|
@@ -204,7 +207,7 @@ with gr.Blocks(css=css) as demo:
|
|
204 |
"0(Gabby's Acquisition)",
|
205 |
"+100%(Budding & Novice)",
|
206 |
"+200%(Junior & Practiced)",
|
207 |
-
"+300%(Natural & Master
|
208 |
],
|
209 |
value="0(Gabby's Acquisition)",
|
210 |
type="index",
|
|
|
94 |
and inventory constraints.
|
95 |
|
96 |
Args:
|
97 |
+
*args (tuple): A tuple containing:
|
98 |
+
- budget (int): Gabby's gold budget.
|
99 |
+
- strategy (str): The selected strategy for selling plants ("MaximizeStock" or "MinimizeStock").
|
100 |
+
- extra_rate (int): The premium rate for selling plants.
|
101 |
+
- stocks (list of int): Stock levels of each plant type.
|
102 |
|
103 |
Returns:
|
104 |
str: A description of the optimal solution, including which plants to sell,
|
105 |
the total gold earned, and the remaining inventory.
|
106 |
+
Returns an error message if no solution is found.
|
107 |
"""
|
108 |
budget: int = args[0] # 葭碧预算
|
109 |
strategy: str = args[1] # 出售策略
|
|
|
145 |
|
146 |
# 求解问题
|
147 |
# CBC(Coin-or Branch and Cut)求解器使用分支定界算法来寻找整数规划问题的最优解
|
148 |
+
solver = pulp.PULP_CBC_CMD(mip=True, msg=False)
|
149 |
prob.solve(solver=solver)
|
150 |
|
151 |
if pulp.LpStatus[prob.status] == "Optimal":
|
|
|
207 |
"0(Gabby's Acquisition)",
|
208 |
"+100%(Budding & Novice)",
|
209 |
"+200%(Junior & Practiced)",
|
210 |
+
"+300%(Natural & Master)",
|
211 |
],
|
212 |
value="0(Gabby's Acquisition)",
|
213 |
type="index",
|