Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import json,pulp
|
3 |
def fx(x,y):
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return resu
|
13 |
|
14 |
title = "测试WEB APP"
|
15 |
description = """
|
@@ -20,4 +19,4 @@ description = """
|
|
20 |
"""
|
21 |
article = "加入[组团吹水](https://qm.qq.com/cgi-bin/qm/qr?k=ueJ_sPuOGHOlzSsUC5lVTBdKpQP-PXbO&jump_from=webapi),你不来我不老!"
|
22 |
|
23 |
-
gr.Interface(fn=fx,inputs=[gr.Textbox(placeholder='请输入凑数序列,如"1,3,5,10,16,54,32,48,6,7"',label="请输入待凑数序列",show_label=True),gr.Number(label="请输入凑数和值",show_label=True)],outputs=gr.JSON(label="输出运算结果",show_label=True),title = title, description = description, article = article).launch()
|
|
|
1 |
import gradio as gr
|
2 |
import json,pulp
|
3 |
def fx(x,y):
|
4 |
+
m=pulp.LpProblem()
|
5 |
+
x=list(map(int,x.split(',')))
|
6 |
+
t=[pulp.LpVariable('t'+str(i),cat=pulp.LpBinary) for i in range(len(x))]
|
7 |
+
m+=pulp.lpDot(x,t)
|
8 |
+
m+=(pulp.lpDot(x,t)==y)
|
9 |
+
m.solve()
|
10 |
+
resu={'data':[x[i] for i in range(len(t)) if pulp.value(t[i])]}
|
11 |
+
return resu
|
|
|
12 |
|
13 |
title = "测试WEB APP"
|
14 |
description = """
|
|
|
19 |
"""
|
20 |
article = "加入[组团吹水](https://qm.qq.com/cgi-bin/qm/qr?k=ueJ_sPuOGHOlzSsUC5lVTBdKpQP-PXbO&jump_from=webapi),你不来我不老!"
|
21 |
|
22 |
+
gr.Interface(fn=fx,inputs=[gr.Textbox(placeholder='请输入凑数序列,如"1,3,5,10,16,54,32,48,6,7"',label="请输入待凑数序列",show_label=True),gr.Number(value=80,label="请输入凑数和值",show_label=True)],outputs=gr.JSON(value="",label="输出运算结果",show_label=True),title = title, description = description, article = article).launch()
|