Skip to content

Commit 4651e3a

Browse files
committed
Add example: op-check-solution-feasibility.c (#7)
1 parent 43309a0 commit 4651e3a

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed
+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#include <op-solver/op-solver.h>
2+
#include <op-solver/op/op.h>
3+
4+
int
5+
main(void)
6+
{
7+
solver_data *data;
8+
data = data_read("test.oplib", 0);
9+
10+
if (data->prob == SOLVER_PROB_OP)
11+
{
12+
op_env *op_env = op_create_env();
13+
op_prob *op = op_create_prob(data);
14+
15+
int ns = 15;
16+
int cycle[15] = {0, 13, 46, 20, 35, 27, 7, 18,
17+
43, 45, 15, 12, 11, 23, 14};
18+
19+
op_sol *sol = cp_get_sol_from_cycle(op, ns, cycle);
20+
21+
cp_print_sol(op, sol);
22+
23+
if (sol->cap > op->cap)
24+
printf(
25+
"\nInfeasible solution: solution cap %.0f > problem cap %0.f\n",
26+
sol->cap, op->cap);
27+
else
28+
printf(
29+
"\nFeasible solution: solution cap %.0f <= problem cap %0.f\n",
30+
sol->cap, op->cap);
31+
32+
op_free_sol(&sol);
33+
op_free_prob(&op);
34+
op_free_env(&op_env);
35+
}
36+
37+
return 0;
38+
}
39+
40+
/*
41+
NAME : att48
42+
COMMENT : 48 capitals of the US (Padberg/Rinaldi)
43+
TYPE : OP
44+
DIMENSION : 48
45+
COST_LIMIT : 2657
46+
EDGE_WEIGHT_TYPE : ATT
47+
NODE_COORD_SECTION
48+
1 6823 4674
49+
2 7692 2247
50+
3 9135 6748
51+
4 7721 3451
52+
5 8304 8580
53+
6 7501 5899
54+
7 4687 1373
55+
8 5429 1408
56+
9 7877 1716
57+
10 7260 2083
58+
11 7096 7869
59+
12 6539 3513
60+
13 6272 2992
61+
14 6471 4275
62+
15 7110 4369
63+
16 6462 2634
64+
17 8476 2874
65+
18 3961 1370
66+
19 5555 1519
67+
20 4422 1249
68+
21 5584 3081
69+
22 5776 4498
70+
23 8035 2880
71+
24 6963 3782
72+
25 6336 7348
73+
26 8139 8306
74+
27 4326 1426
75+
28 5164 1440
76+
29 8389 5804
77+
30 4639 1629
78+
31 6344 1436
79+
32 5840 5736
80+
33 5972 2555
81+
34 7947 4373
82+
35 6929 8958
83+
36 5366 1733
84+
37 4550 1219
85+
38 6901 1589
86+
39 6316 5497
87+
40 7010 2710
88+
41 9005 3996
89+
42 7576 7065
90+
43 4246 1701
91+
44 5906 1472
92+
45 6469 8971
93+
46 6152 2174
94+
47 5887 3796
95+
48 7203 5958
96+
NODE_SCORE_SECTION
97+
1 0
98+
2 1
99+
3 1
100+
4 1
101+
5 1
102+
6 1
103+
7 1
104+
8 1
105+
9 1
106+
10 1
107+
11 1
108+
12 1
109+
13 1
110+
14 1
111+
15 1
112+
16 1
113+
17 1
114+
18 1
115+
19 1
116+
20 1
117+
21 1
118+
22 1
119+
23 1
120+
24 1
121+
25 1
122+
26 1
123+
27 1
124+
28 1
125+
29 1
126+
30 1
127+
31 1
128+
32 1
129+
33 1
130+
34 1
131+
35 1
132+
36 1
133+
37 1
134+
38 1
135+
39 1
136+
40 1
137+
41 1
138+
42 1
139+
43 1
140+
44 1
141+
45 1
142+
46 1
143+
47 1
144+
48 1
145+
DEPOT_SECTION
146+
1
147+
-1
148+
EOF
149+
*/

0 commit comments

Comments
 (0)