Skip to content

Commit 37f08c6

Browse files
committed
README and golden tests
1 parent 3b0b224 commit 37f08c6

5 files changed

Lines changed: 278 additions & 0 deletions

File tree

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
{
2+
"FACILITIES": ["Elm Creek", "Emory", "Sunset"],
3+
"CUSTOMERS": [
4+
"Temple",
5+
"Joshua",
6+
"Moody",
7+
"Kirvin",
8+
"Miller's Cove",
9+
"Guadalupe Guerra"
10+
],
11+
"SCENARIOS": ["S1", "S2", "S3", "S4", "S5"],
12+
"prob": {
13+
"S1": 0.2,
14+
"S2": 0.2,
15+
"S3": 0.2,
16+
"S4": 0.2,
17+
"S5": 0.2
18+
},
19+
"fixed_cost": [
20+
{
21+
"City": "Elm Creek",
22+
"FixedCost": 1000000
23+
},
24+
{
25+
"City": "Emory",
26+
"FixedCost": 600000
27+
},
28+
{
29+
"City": "Sunset",
30+
"FixedCost": 800000
31+
}
32+
],
33+
"facility_capacity": [
34+
{
35+
"City": "Elm Creek",
36+
"Capacity": 2000
37+
},
38+
{
39+
"City": "Emory",
40+
"Capacity": 1900
41+
},
42+
{
43+
"City": "Sunset",
44+
"Capacity": 1600
45+
}
46+
],
47+
"variable_cost": [
48+
{
49+
"Facility": "Elm Creek",
50+
"Customer": "Guadalupe Guerra",
51+
"Distance": 297.623890758
52+
},
53+
{
54+
"Facility": "Elm Creek",
55+
"Customer": "Joshua",
56+
"Distance": 505.6606318977
57+
},
58+
{
59+
"Facility": "Elm Creek",
60+
"Customer": "Kirvin",
61+
"Distance": 519.6437634702
62+
},
63+
{
64+
"Facility": "Elm Creek",
65+
"Customer": "Miller's Cove",
66+
"Distance": 706.6827570413
67+
},
68+
{
69+
"Facility": "Elm Creek",
70+
"Customer": "Moody",
71+
"Distance": 412.2824400838
72+
},
73+
{
74+
"Facility": "Elm Creek",
75+
"Customer": "Temple",
76+
"Distance": 395.3941518648
77+
},
78+
{
79+
"Facility": "Emory",
80+
"Customer": "Guadalupe Guerra",
81+
"Distance": 786.9389368793
82+
},
83+
{
84+
"Facility": "Emory",
85+
"Customer": "Joshua",
86+
"Distance": 158.3719269502
87+
},
88+
{
89+
"Facility": "Emory",
90+
"Customer": "Kirvin",
91+
"Distance": 134.2084779985
92+
},
93+
{
94+
"Facility": "Emory",
95+
"Customer": "Miller's Cove",
96+
"Distance": 68.3531229709
97+
},
98+
{
99+
"Facility": "Emory",
100+
"Customer": "Moody",
101+
"Distance": 229.9660680318
102+
},
103+
{
104+
"Facility": "Emory",
105+
"Customer": "Temple",
106+
"Distance": 249.2073236813
107+
},
108+
{
109+
"Facility": "Sunset",
110+
"Customer": "Guadalupe Guerra",
111+
"Distance": 792.6791149946
112+
},
113+
{
114+
"Facility": "Sunset",
115+
"Customer": "Joshua",
116+
"Distance": 115.6918553125
117+
},
118+
{
119+
"Facility": "Sunset",
120+
"Customer": "Kirvin",
121+
"Distance": 230.2851131675
122+
},
123+
{
124+
"Facility": "Sunset",
125+
"Customer": "Miller's Cove",
126+
"Distance": 248.5501694133
127+
},
128+
{
129+
"Facility": "Sunset",
130+
"Customer": "Moody",
131+
"Distance": 240.935931368
132+
},
133+
{
134+
"Facility": "Sunset",
135+
"Customer": "Temple",
136+
"Distance": 262.7329591493
137+
}
138+
],
139+
"customer_demand": [
140+
{
141+
"City": "Guadalupe Guerra",
142+
"S1": 470,
143+
"S2": 425,
144+
"S3": 495,
145+
"S4": 620,
146+
"S5": 372
147+
},
148+
{
149+
"City": "Joshua",
150+
"S1": 561,
151+
"S2": 534,
152+
"S3": 585,
153+
"S4": 542,
154+
"S5": 491
155+
},
156+
{
157+
"City": "Kirvin",
158+
"S1": 135,
159+
"S2": 132,
160+
"S3": 234,
161+
"S4": 242,
162+
"S5": 177
163+
},
164+
{
165+
"City": "Miller's Cove",
166+
"S1": 432,
167+
"S2": 342,
168+
"S3": 565,
169+
"S4": 547,
170+
"S5": 394
171+
},
172+
{
173+
"City": "Moody",
174+
"S1": 482,
175+
"S2": 449,
176+
"S3": 288,
177+
"S4": 393,
178+
"S5": 458
179+
},
180+
{
181+
"City": "Temple",
182+
"S1": 298,
183+
"S2": 343,
184+
"S3": 387,
185+
"S4": 349,
186+
"S5": 375
187+
}
188+
]
189+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"options": {
3+
"input": "",
4+
"output": "",
5+
"duration": 30,
6+
"epsilon": 1e-05,
7+
"max_iterations": 100
8+
},
9+
"solution": {
10+
"facilities": [
11+
"Elm Creek",
12+
"Emory"
13+
],
14+
"total_cost": 2076052.9158463147,
15+
"fixed_cost": 1600000.0,
16+
"variable_cost": 476052.9158463148
17+
},
18+
"statistics": {
19+
"run": {
20+
"duration": 0.02388477325439453
21+
},
22+
"result": {
23+
"duration": 0.0,
24+
"value": 2076052.9158463147,
25+
"custom": {
26+
"status": "optimal",
27+
"iterations": 4
28+
}
29+
},
30+
"schema": "v1"
31+
},
32+
"assets": []
33+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package mip
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/nextmv-io/sdk/golden"
8+
)
9+
10+
func TestMain(m *testing.M) {
11+
code := m.Run()
12+
os.Exit(code)
13+
}
14+
15+
func TestGolden(t *testing.T) {
16+
golden.FileTests(
17+
t,
18+
"inputs",
19+
golden.Config{
20+
Args: []string{
21+
"-duration",
22+
"30",
23+
},
24+
TransientFields: []golden.TransientField{
25+
{
26+
Key: "$.statistics.result.duration",
27+
Replacement: golden.StableFloat,
28+
},
29+
{
30+
Key: "$.statistics.run.duration",
31+
Replacement: golden.StableFloat,
32+
},
33+
{
34+
Key: "$.options.output",
35+
Replacement: "output.json",
36+
},
37+
{
38+
Key: "$.options.input",
39+
Replacement: "input.json",
40+
},
41+
},
42+
// We ignore stdout here, as it may contain community license
43+
// warnings depending on whether a license was set up or not (not
44+
// the intention of the test).
45+
IgnoreStdOut: true,
46+
ExecutionConfig: &golden.ExecutionConfig{
47+
Command: "python3",
48+
Args: []string{"../../../python-xpress-facility-location/main.py"},
49+
InputFlag: "-input",
50+
OutputFlag: "-output",
51+
},
52+
},
53+
)
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip3 install -r requirements.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python3 main.py -input input.json -output output.json -duration 30

0 commit comments

Comments
 (0)