Skip to content

Commit

Permalink
add nodelink problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jifwin committed Dec 18, 2016
1 parent e3f6250 commit 70aeef4
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nodelink/.oplproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="ASCII"?><project>
<version>1.0</version>
<configs>
<config category="opl" default="true" name="Konfiguracja1">
<ref name="nodelink.mod" type="model">
</ref>
<ref name="nodelink.ops" type="setting">
</ref>
<ref name="nodelink.dat" type="data">
</ref>
</config>
</configs>

</project>
12 changes: 12 additions & 0 deletions nodelink/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>nodelink</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>ilog.odms.ide.core.opl.project.nature</nature>
</natures>
</projectDescription>
67 changes: 67 additions & 0 deletions nodelink/nodelink.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*********************************************
* OPL 12.6.3.0 Data
* Author: grzegorz
* Creation Date: 18-12-2016 at 11:05:20
*********************************************/

v = { 1 2 3 4 5 6 7 8 9 10 };
d = { 1 2 };
e = { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 };

a =
[
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] //1
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ] //2
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ] //3
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ] //4
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ] //5
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] //6
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ] //7
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ] //8
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] //9
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ] //10
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ] //11
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ] //12
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] //13
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ] //14
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] //15
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] //16
];

b =
[
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ] //1
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ] //2
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ] //3
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ] //4
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ] //5
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ] //6
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] //7
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ] //8
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ] //9
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ] //10
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] //11
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] //12
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ] //13
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] //14
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] //15
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ] //16
];


// source node of demand d
s = [ 1 2 ];

// sink node of demand d
t = [ 10 8 ];

//volume of demand d
h = [ 10 10 ];

//links costs
ksi = [ 30 40 30 35 90 50 10 10 90 10 35 10 25 30 15 45 ];

//links capacities
cap = [ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ]; //lack of capacity
//cap = [ 5 10 10 5 5 5 5 5 5 5 5 5 5 5 5 5 ]; //10 for 2 and 3 edge
//cap = [ 5 5 5 5 5 5 5 5 5 5 5 5 10 5 10 5 ]; //10 for 13 and 13 edge
56 changes: 56 additions & 0 deletions nodelink/nodelink.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*********************************************
* OPL 12.6.3.0 Model
* Author: grzegorz
* Creation Date: 18-12-2016 at 11:05:20
*********************************************/

{int} e = ...;
{int} v = ...;
{int} d = ...;


int a[e][v] = ...;
int b[e][v] = ...;
int ksi[e] = ...;
int s[d] = ...;
int t[d] = ...;
int h[d] = ...;
int cap[e] = ...;


dvar float+ x[e][d];
dvar float+ y[e];

minimize
sum(edge in e) ksi[edge]*y[edge];

subject to {

forall (edge in e) {
sum(demand in d) x[edge][demand] <= y[edge];
}


forall (demand in d) {
forall (node in v) {

if (node == s[demand]) {
sum(edge in e) a[edge][node]*x[edge][demand] - sum(edge in e) b[edge][node]*x[edge][demand] == h[demand];
}

else if (node == t[demand]) {
sum(edge in e) a[edge][node]*x[edge][demand] - sum(edge in e) b[edge][node]*x[edge][demand] == -1*h[demand];
}

else {
sum(edge in e) a[edge][node]*x[edge][demand] - sum(edge in e) b[edge][node]*x[edge][demand] == 0;
}

}
}

forall (edge in e) {
y[edge] <= cap[edge];
}

}
3 changes: 3 additions & 0 deletions nodelink/nodelink.ops
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>

<settings version="2"/>

0 comments on commit 70aeef4

Please sign in to comment.