Minizinc Model Panel |
---|
title | MiniZinc model for the example application (budget constrained network flow optimization model). This model can be composed from different components, each independently contributed by contrbutors with different expertise and roles, as described above. |
---|
| int: N; % input nodes int: M; % output nodes int: maxbw; float: budget;
set of int: inNodes = 1..N;
set of int: outNodes = 1..M;
array[inNodes] of int: inCap; array[outNodes] of int: outCap;
array[inNodes, outNodes] of int: bw; array[inNodes, outNodes] of float: cost; array[inNodes, outNodes] of var 0..maxbw: x;
constraint forall (i in inNodes) (sum (j in outNodes) (x[i,j]) <= inCap[i]);
constraint forall (j in outNodes) (sum (i in inNodes) (x[i,j]) <= outCap[j]);
constraint forall (i in inNodes, j in outNodes) (x[i,j] <= bw[i,j]);
constraint sum (i in inNodes, j in outNodes) (x[i,j] * cost[i,j]) <= budget;
% another "stringent" service-specific policy constraint sum (i in inNodes, j in outNodes) (x[i,j] * cost[i,j]) <= 0.8 * budget;
var flow = sum (i in inNodes, j in outNodes) (x[i,j]);
constraint forall (i in inNodes, j in outNodes) (x[i,j] <= 0.2 * flow);
solve maximize sum (i in inNodes, j in outNodes) (x[i,j]); |
Minizinc Data Template Panel |
---|
title | Data file used in the for the example application. The file format is dzn (Minizinc data format) and the file uses the widely used jinja2 templating for Python, with support for OOF to objects such as "input" (the input API request), SDC (a dummy object that provides network capacities of nodes, as well as information on cost per unit network utilization for each network edge), and AAI (another dummy object that provides network capacities of nodes, and also bandwith for links among different nodes). This data template is rendered into a data file (dzn format), which, together with the model file defines a complete optimization problem. |
---|
| % Relevant calls to APIs
{% inNodes, outNodes, budget = input.get("inNodes", "outNodes", "budget") %}
{% inCap, outCap = AAI.getCapacities(inNodes, outNodes) %};
{% bw = AAI.getBandwidthMatrix(inNodes, outNodes) %};
{% cost = SDC.getNetworkCostMatrix(inNodes, outNodes) %};
N = {{ len(inNodes) }};
M = {{ len(outNodes) }};
maxbw = {{ max(max(bw)) }};
budget = {{ budget }};
inCap = {{ inCap }};
outCap = {{ outCap }};
bw = {{ mzn.toMatrix(bw) }}; % writes it out as minizinc matrix
cost = {{ mzn.toMatrix(cost) }}; |
Minizinc Data File Panel |
---|
title | Rendered Minizinc Data File (from Template) |
---|
| N = 5;
M = 4;
maxbw = 20;
budget = 50;
inCap = [10, 5, 0, 4, 20];
outCap = [10, 0, 5, 4];
bw = [| 10, 5, 0, 0
| 2, 4, 10, 0
| 4, 4, 10, 0
| 2, 0, 0, 5
| 0, 0, 0, 1 |];
cost = [| 1, 1, 10, 20
| 90, 90, 90, 90
| 2, 1, 1, 1
| 2, 10, 10, 1
| 9, 9, 9, 99.9 |]; |
|