Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio
|
2 |
+
import kaboom
|
3 |
+
|
4 |
+
def run_kaboom(reps):
|
5 |
+
from kaboom.carMakers import runCarDesignProblem
|
6 |
+
|
7 |
+
#create a parameters object
|
8 |
+
#parameters (p.nAgents = 33, p.nTeams = 11, p.nDims = 56) are automatically set for this problem.
|
9 |
+
parameters = kaboom.params.Params()
|
10 |
+
parameters.reps = reps
|
11 |
+
|
12 |
+
#run the simulation with the car designer objective
|
13 |
+
team = runCarDesignProblem(parameters)
|
14 |
+
|
15 |
+
#check the performance of the team
|
16 |
+
#invert score *-1 so that higher score = better performance
|
17 |
+
return team.getBestScore()*-1
|
18 |
+
|
19 |
+
gradio.Interface(
|
20 |
+
fn = run_kaboom, inputs = [gradio.Number(label="Number of teams")], outputs = [gradio.Number(label="Performance")]
|
21 |
+
).launch()
|