Skip to content

Instantly share code, notes, and snippets.

View bokner's full-sized avatar

Boris Okner bokner

  • Barrie, ON, Canada
View GitHub Profile
include "globals.mzn";
int: N;
int: E;
set of int: NODES = 1..N;
set of int: EDGES = 1..E;
array[EDGES] of int: from;
array[EDGES] of int: to;
include "globals.mzn";
int: N;
int: T;
set of int: WORKERS = 1..N;
set of int: TASKS = 1..T;
array[TASKS, WORKERS] of int: costs;
int: W;
int: C;
set of int: WAREHOUSE = 1..W;
set of int: CLIENT = 1..C;
array[WAREHOUSE] of int: max_demand;
array[WAREHOUSE] of float: fixed_cost;
include "globals.mzn";
int: R = 4;
int: T = 4;
int: C = 4;
int: S = 30;
set of int: ROOM = 1..R;
set of int: CLASS = 1..C;
set of int: TEACHER = 1..T;
@bokner
bokner / advent_or_day6.mzn
Last active January 16, 2025 04:54
advent_or_day6.mzn
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;
include "globals.mzn";
% Number of items
int: N;
% Bin capacity
int: C;
set of int: ITEMS = 1..N;
include "globals.mzn";
% Number of components
int: N;
set of int: COMPONENTS = 1..N;
% Number of connections
int: C;
set of int: CONNECTIONS = 1..C;
include "globals.mzn";
include "gecode.mzn";
%
% Data
%
int: N; % number of nodes
set of int: NODE = 1..N;
array[NODE, NODE] of int: distances; % distance matrix
%% Method: we build a directed graph, with edges
%% {from, to} representing a pair of consequent non-overlapping tasks.
%% That is, `end_time(from) < start_time(to)`
%% Then we constrain a list of tasks for each crew as a path in this graph.
%% Finally, we constrain the lists to be disjoint.
include "globals.mzn";
int: T;
int: C;
include "globals.mzn";
int: N;
set of int: LOCATION = 1..N;
array[LOCATION, LOCATION] of int: flow;
array[LOCATION, LOCATION] of int: distances;
array[LOCATION] of var LOCATION: location_assignments;
constraint alldifferent(location_assignments);