Last active
January 16, 2025 04:54
-
-
Save bokner/f739ce955194741d34fd38843e4b98fe to your computer and use it in GitHub Desktop.
advent_or_day6.mzn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "globals.mzn"; | |
int: NUM_SEGMENTS; | |
int: NUM_SUBSETS; | |
set of int: SUBSETS = 1..NUM_SUBSETS; | |
set of int: SEGMENTS = 1..NUM_SEGMENTS; | |
array[SUBSETS] of set of int: combinations; | |
array[SUBSETS] of int: costs; | |
array[SUBSETS] of var bool: selected; | |
var min(costs)..sum(costs): total_cost; | |
constraint total_cost = | |
sum(c in SUBSETS)(selected[c] * costs[c]); | |
constraint forall(s in SEGMENTS)( | |
sum(c in SUBSETS where s in combinations[c])(selected[c]) >=1 | |
); | |
constraint forall(c in SUBSETS)( | |
sum(combinations[c]) > 0 <- selected[c] | |
); | |
solve minimize total_cost; | |
List of subsets:
[246, 248, 352, 568, 611, 1393, 2010, 2064, 2441, 2850, 2949, 3042, 3115, 3155,
3173, 3259, 3307, 3458, 4667, 5235, 5891, 6230, 6860, 6883, 7179, 7280, 9029,
9188, 9261, 9262, 9342, 9964, 10374, 10684, 11016, 11397, 11595, 11812, 11969,
12130, 12322, 12392, 12487, 12646, 12875, 13103, 13298, 14452, 15763, 18529,
18538, 19940, 20647, 20668, 20669, 22386, 23622, 23901, 25974, 27080, 27849,
30827, 33131, 33190, 36507, 37778, 38063, 38217, 38382, 39017, 39077, 39119,
39663, 39709, 40633, 40833, 41165, 41196, 41385, 41744, 42315, 42658, 42833,
43829, 44804, 44977, 45717, 47877, 48923, 49228, 52110, 53276, 55671, 55675,
55760, 55810, 56144, 56642, 56704, 56893, 56922, 56965, 57150, 57906, 57922,
60233, 60594, 61650, 62336, 62363]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Best solution: total_cost = 169 (CBC-COIN)