Skip to content

Commit 6704ab9

Browse files
committed
update options
1 parent 56f61ef commit 6704ab9

File tree

3 files changed

+144
-2
lines changed

3 files changed

+144
-2
lines changed

python-xpress-facility-location/app.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,24 @@ python:
1010
files:
1111
- main.py
1212
- visuals.py
13+
14+
configuration:
15+
options:
16+
strict: false
17+
validation:
18+
enforce: none
19+
items:
20+
- name: objective
21+
option_type: string
22+
default: "average_distance"
23+
required: false
24+
description: "minimizes for average_distance, total_distance, or max_distance"
25+
additional_attributes:
26+
values:
27+
- "average_distance"
28+
- "total_distance"
29+
- "max_distance"
30+
ui:
31+
control_type: select
32+
hidden_from:
33+
- operator

python-xpress-facility-location/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def main() -> None:
2626
nextmv.Option("input", str, "", "Path to input file. Default is stdin.", False),
2727
nextmv.Option("output", str, "", "Path to output file. Default is stdout.", False),
2828
nextmv.Option("objective", str, "average_distance", "minimizes for average_distance, total_distance, or max_distance", False),
29-
nextmv.Option("parks_override", int, 4, "number of parks to build", False),
29+
nextmv.Option("parks_override", int, None, "number of parks to build (from 1 to 10)", False),
3030
)
3131

3232
input = nextmv.load(options=options, path=options.input)
@@ -106,10 +106,17 @@ def main() -> None:
106106
coord_sites=coord_sites,
107107
SCHOOLS=SCHOOLS,
108108
SITES=SITES)
109+
sol = prob.getSolution(serves)
110+
average_distance = sum(dist[i,j] * sol[i,j] for i in SCHOOLS for j in SITES) / input.data.get('num_schools')
111+
total_distance = sum(dist[i,j] * sol[i,j] for i in SCHOOLS for j in SITES)
112+
max_distance = max(dist[i,j] for i in SCHOOLS for j in SITES if sol[i,j] > 0.5)
113+
nextmv.log(f"average_distance: {average_distance}")
114+
nextmv.log(f"total_distance: {total_distance}")
115+
nextmv.log(f"max_distance: {max_distance}")
109116

110117
output = nextmv.Output(
111118
solution={"solution": solution},
112-
statistics={"result": {"value": value}, "schema": "v1"},
119+
statistics={"result": {"value": value, "custom": {"average_distance": average_distance, "total_distance": total_distance, "max_distance": max_distance}}, "schema": "v1"},
113120
assets=[input_charts, output_charts]
114121
)
115122

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
\Written from user model (presolvestate=0x5c00e1)
2+
\Problem name: noname
3+
\FICO Xpress v9.6.0, Community, written 17:36:53, Jul 10, 2025
4+
5+
Minimize
6+
__OBJ___: 7.091122155645802 x(0,0) + 2.589998816611848 x(0,1) + 7.6504613490039 x(0,2)
7+
+ 5.28533356671592 x(0,3) + 5.15774165404805 x(0,4)
8+
+ 5.927524698936247 x(0,5) + 5.0204122097792 x(0,6)
9+
+ 3.2856023258532194 x(0,7) + 7.361678099656025 x(0,8)
10+
+ 10.415569427472557 x(0,9) + 9.441734365015757 x(0,10)
11+
+ 2.861801578860992 x(1,0) + 6.1343665056576375 x(1,1)
12+
+ 2.7080552121416894 x(1,2) + 3.686267648744095 x(1,3)
13+
+ 2.362001443179578 x(1,4) + 1.4871113444452866 x(1,5)
14+
+ 2.846720000340132 x(1,6) + 5.100527859851427 x(1,7)
15+
+ 7.041670286855928 x(1,8) + 5.257670082742286 x(1,9)
16+
+ 5.994065069317083 x(1,10) + 6.447235947239159 x(2,0)
17+
+ 0.9362928699496558 x(2,1) + 4.6644431917854465 x(2,2)
18+
+ 2.1675752010366844 x(2,3) + 3.1203175496121576 x(2,4)
19+
+ 4.057448679453809 x(2,5) + 4.268431108468661 x(2,6)
20+
+ 4.208742814454888 x(2,7) + 4.1504725408445555 x(2,8)
21+
+ 7.159150622647894 x(2,9) + 6.042738135784493 x(2,10)
22+
+ 7.211769200535987 x(3,0) + 7.078399660967762 x(3,1)
23+
+ 1.9541442876840311 x(3,2) + 4.074765411311135 x(3,3)
24+
+ 4.871904936487138 x(3,4) + 4.796289770381407 x(3,5)
25+
+ 6.524638104817834 x(3,6) + 8.364648412688208 x(3,7)
26+
+ 4.7225284365560345 x(3,8) + 1.0822985194778998 x(3,9)
27+
+ 2.021698763031933 x(3,10) + 9.760472349633416 x(4,0)
28+
+ 3.772933824507494 x(4,1) + 6.203742731707887 x(4,2)
29+
+ 4.403045669823555 x(4,3) + 6.178560013669201 x(4,4)
30+
+ 7.032047735946573 x(4,5) + 7.696714781278531 x(4,6)
31+
+ 7.7474486678559185 x(4,7) + 2.2645734483956694 x(4,8)
32+
+ 7.423910578671469 x(4,9) + 5.516554382161167 x(4,10)
33+
+ 3.332420097642088 x(5,0) + 8.236986664073898 x(5,1)
34+
+ 4.187384508050594 x(5,2) + 5.736376369189847 x(5,3)
35+
+ 4.454136821956518 x(5,4) + 3.5408474136181707 x(5,5)
36+
+ 4.4807589240991685 x(5,6) + 6.723194421354005 x(5,7)
37+
+ 8.831280192399626 x(5,8) + 5.848273251138301 x(5,9)
38+
+ 7.173800277549954 x(5,10) + 9.359683673098754 x(6,0)
39+
+ 6.534540541785503 x(6,1) + 4.033309011264027 x(6,2)
40+
+ 4.448089866963538 x(6,3) + 6.13819441083058 x(6,4)
41+
+ 6.525258116061773 x(6,5) + 8.01330711492873 x(6,6)
42+
+ 9.250488025395569 x(6,7) + 2.285019058733945 x(6,8)
43+
+ 3.350720359413925 x(6,9) + 1.2191053288354055 x(6,10)
44+
+ 1.4653099293560534 x(7,0) + 5.423800800698032 x(7,1)
45+
+ 4.43579288874122 x(7,2) + 4.1152174127516075 x(7,3)
46+
+ 2.187373182068374 x(7,4) + 1.6262997411820497 x(7,5)
47+
+ 0.9117951531645557 x(7,6) + 3.0861038926034214 x(7,7)
48+
+ 7.866084509017328 x(7,8) + 7.3131128445023466 x(7,9)
49+
+ 7.6584828467010695 x(7,10) + 4.659382160742719 x(8,0)
50+
+ 2.3351329081413836 x(8,1) + 5.172171071738241 x(8,2)
51+
+ 3.139420263618541 x(8,3) + 2.444801105472683 x(8,4)
52+
+ 3.172911488022324 x(8,5) + 2.4446193576240955 x(8,6)
53+
+ 1.8888561292713706 x(8,7) + 6.313576341414102 x(8,8)
54+
+ 8.108917434503335 x(8,9) + 7.531702581487825 x(8,10)
55+
56+
Subject To
57+
R1: x(0,0) + x(0,1) + x(0,2) + x(0,3) + x(0,4) + x(0,5) + x(0,6) + x(0,7)
58+
+ x(0,8) + x(0,9) + x(0,10) = 1
59+
R2: x(1,0) + x(1,1) + x(1,2) + x(1,3) + x(1,4) + x(1,5) + x(1,6) + x(1,7)
60+
+ x(1,8) + x(1,9) + x(1,10) = 1
61+
R3: x(2,0) + x(2,1) + x(2,2) + x(2,3) + x(2,4) + x(2,5) + x(2,6) + x(2,7)
62+
+ x(2,8) + x(2,9) + x(2,10) = 1
63+
R4: x(3,0) + x(3,1) + x(3,2) + x(3,3) + x(3,4) + x(3,5) + x(3,6) + x(3,7)
64+
+ x(3,8) + x(3,9) + x(3,10) = 1
65+
R5: x(4,0) + x(4,1) + x(4,2) + x(4,3) + x(4,4) + x(4,5) + x(4,6) + x(4,7)
66+
+ x(4,8) + x(4,9) + x(4,10) = 1
67+
R6: x(5,0) + x(5,1) + x(5,2) + x(5,3) + x(5,4) + x(5,5) + x(5,6) + x(5,7)
68+
+ x(5,8) + x(5,9) + x(5,10) = 1
69+
R7: x(6,0) + x(6,1) + x(6,2) + x(6,3) + x(6,4) + x(6,5) + x(6,6) + x(6,7)
70+
+ x(6,8) + x(6,9) + x(6,10) = 1
71+
R8: x(7,0) + x(7,1) + x(7,2) + x(7,3) + x(7,4) + x(7,5) + x(7,6) + x(7,7)
72+
+ x(7,8) + x(7,9) + x(7,10) = 1
73+
R9: x(8,0) + x(8,1) + x(8,2) + x(8,3) + x(8,4) + x(8,5) + x(8,6) + x(8,7)
74+
+ x(8,8) + x(8,9) + x(8,10) = 1
75+
R10: x(0) + x(1) + x(2) + x(3) + x(4) + x(5) + x(6) + x(7) + x(8) + x(9)
76+
+ x(10) = 4
77+
R11: x(0,0) + x(1,0) + x(2,0) + x(3,0) + x(4,0) + x(5,0) + x(6,0) + x(7,0)
78+
+ x(8,0) - 9 x(0) <= 0
79+
R12: x(0,1) + x(1,1) + x(2,1) + x(3,1) + x(4,1) + x(5,1) + x(6,1) + x(7,1)
80+
+ x(8,1) - 9 x(1) <= 0
81+
R13: x(0,2) + x(1,2) + x(2,2) + x(3,2) + x(4,2) + x(5,2) + x(6,2) + x(7,2)
82+
+ x(8,2) - 9 x(2) <= 0
83+
R14: x(0,3) + x(1,3) + x(2,3) + x(3,3) + x(4,3) + x(5,3) + x(6,3) + x(7,3)
84+
+ x(8,3) - 9 x(3) <= 0
85+
R15: x(0,4) + x(1,4) + x(2,4) + x(3,4) + x(4,4) + x(5,4) + x(6,4) + x(7,4)
86+
+ x(8,4) - 9 x(4) <= 0
87+
R16: x(0,5) + x(1,5) + x(2,5) + x(3,5) + x(4,5) + x(5,5) + x(6,5) + x(7,5)
88+
+ x(8,5) - 9 x(5) <= 0
89+
R17: x(0,6) + x(1,6) + x(2,6) + x(3,6) + x(4,6) + x(5,6) + x(6,6) + x(7,6)
90+
+ x(8,6) - 9 x(6) <= 0
91+
R18: x(0,7) + x(1,7) + x(2,7) + x(3,7) + x(4,7) + x(5,7) + x(6,7) + x(7,7)
92+
+ x(8,7) - 9 x(7) <= 0
93+
R19: x(0,8) + x(1,8) + x(2,8) + x(3,8) + x(4,8) + x(5,8) + x(6,8) + x(7,8)
94+
+ x(8,8) - 9 x(8) <= 0
95+
R20: x(0,9) + x(1,9) + x(2,9) + x(3,9) + x(4,9) + x(5,9) + x(6,9) + x(7,9)
96+
+ x(8,9) - 9 x(9) <= 0
97+
R21: x(0,10) + x(1,10) + x(2,10) + x(3,10) + x(4,10) + x(5,10) + x(6,10)
98+
+ x(7,10) + x(8,10) - 9 x(10) <= 0
99+
100+
Bounds
101+
102+
Binaries
103+
x(0,0) x(0,1) x(0,2) x(0,3) x(0,4) x(0,5) x(0,6) x(0,7) x(0,8) x(0,9) x(0,10)
104+
x(1,0) x(1,1) x(1,2) x(1,3) x(1,4) x(1,5) x(1,6) x(1,7) x(1,8) x(1,9) x(1,10)
105+
x(2,0) x(2,1) x(2,2) x(2,3) x(2,4) x(2,5) x(2,6) x(2,7) x(2,8) x(2,9) x(2,10)
106+
x(3,0) x(3,1) x(3,2) x(3,3) x(3,4) x(3,5) x(3,6) x(3,7) x(3,8) x(3,9) x(3,10)
107+
x(4,0) x(4,1) x(4,2) x(4,3) x(4,4) x(4,5) x(4,6) x(4,7) x(4,8) x(4,9) x(4,10)
108+
x(5,0) x(5,1) x(5,2) x(5,3) x(5,4) x(5,5) x(5,6) x(5,7) x(5,8) x(5,9) x(5,10)
109+
x(6,0) x(6,1) x(6,2) x(6,3) x(6,4) x(6,5) x(6,6) x(6,7) x(6,8) x(6,9) x(6,10)
110+
x(7,0) x(7,1) x(7,2) x(7,3) x(7,4) x(7,5) x(7,6) x(7,7) x(7,8) x(7,9) x(7,10)
111+
x(8,0) x(8,1) x(8,2) x(8,3) x(8,4) x(8,5) x(8,6) x(8,7) x(8,8) x(8,9) x(8,10)
112+
x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) x(8) x(9) x(10)
113+
114+
End

0 commit comments

Comments
 (0)