Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Contents

Table of Contents

...

Section
bordertrue

Minizinc Model

Panel
titleData file used in 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 cost per unit network utilization), and AAI (another dummy object that provides 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.
int: N;  % input nodes 
int: M;  % output nodes 
int: maxbw; % max bandwidth (for convenience) 
float: budget;

set of int: inNodes = 1..N;
set of int: outNodes = 1..M;

array[inNodes] of int: inCap;  % capacities for input nodes 
array[outNodes] of int: outCap;  % capacity for output nodes 
array[inNodes, outNodes] of int: bw;  % max bandwidth of link 
array[inNodes, outNodes] of float: cost;  % unit cost for the link 
array[inNodes, outNodes] of var 0..maxbw: x;  % amount through this link 

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;

Info

% The following policy can due to run-time insertion of a policy specified by the service providercould have been populated by an Ops person (and injected at run-time for each subsequent request)

% another "stringent" service-specific policy 
constraint sum (i in inNodes, j in outNodes) (x[i,j] * cost[i,j]) <= 0.8 * budget;

Info

% Another example of a policy inserted at run-time after evaluation of relevant policies for this service(this could have been defined and added by the service designer)

% each link cannot have more than 20% of traffic from a customer 
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
titleData 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 cost per unit network utilization), and AAI (another dummy object that provides 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 = SDC.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
titleRendered 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 |];

...