Skip to content

Commit

Permalink
Small fix in ILP algorihm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesanov committed Apr 24, 2019
1 parent ac228fa commit 12fa524
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/ILP.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def imp(name, cond, vals): # c[i] >= 0 ===> v[i] >= 0
for e1, (s1, t1, _) in graph.edge.items():
for e2, (s2, t2, _) in graph.edge.items():
if graph.node[s1][y] > graph.node[s2][y] > graph.node[t1][y]:
# crossY = [node[t1,y] - node[s2,y] -1, node[t2,y] - node[t1,y] -1]
e1GTs2 = node[s1] + edge[e1] - node[s2]
e1GTt2 = node[s1] + edge[e1] - node[t2]

m.addConstr(imp(f'R {e1} {e2}', [ edge[e1]], [ e1GTs2 -1]))
m.addConstr(imp(f'L {e1} {e2}', [-edge[e1]], [-e1GTs2 -1]))
m.addConstr(imp(f'R {e1} {e2}', [ edge[e2], e1GTs2], [ e1GTt2 -1]))
m.addConstr(imp(f'L {e1} {e2}', [-edge[e2], -e1GTs2], [-e1GTt2 -1]))
# s.x > e.x > t.x
for e, (s, t, _) in graph.edge.items():
tGTs = node[t] - node[s]
Expand Down
5 changes: 4 additions & 1 deletion src/graph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ readCSV = (fileNodes, fileEdges) ->
e++
yield t

state = new State readCSV '../data/nodes.csv', '../data/edges.csv'
state = new State readCSV '../data/test_nodes.csv', '../data/test_edges.csv'


for graph from state.iter()
graph.nodes[n][0] = r for n, r of graph.ranks
for e, [s,t,o] of graph.edges
graph.edges[e] = [t,s,o] if graph.nodes[s][0] < graph.nodes[t][0]

fs.writeFileSync '../data/graphlayout.json', JSON.stringify
'edges': graph.edges
'nodes': graph.nodes
Expand Down
7 changes: 3 additions & 4 deletions src/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ addNode = ([y, x]) ->

addEdge = ([ys, xs], [yt, xt], offset) ->
line1 = addLine [ys,xs], [ys,xs+offset]
line2 = addLine [yt+.5,xs+offset], [yt+.5,xt]
line3 = addLine [ys,xs+offset], [yt+.5,xs+offset]
line4 = addLine [yt+.5, xt], [yt, xt]
line2 = addLine [yt+.3,xs+offset], [yt+.3,xt]
line3 = addLine [ys,xs+offset], [yt+.3,xs+offset]
line4 = addLine [yt+.3, xt], [yt, xt]
group [line1, line2, line3, line4]

addLine = ([ys, xs], [yt, xt]) ->
Expand All @@ -46,5 +46,4 @@ for _, pos of graph.nodes
for _, pos of graph.nodes
addNode pos
for _, [s, t, offset] of graph.edges
[s, t] = [t, s] if graph.nodes[s][0] < graph.nodes[t][0]
addEdge graph.nodes[s], graph.nodes[t], offset

0 comments on commit 12fa524

Please sign in to comment.