Skip to content

Commit

Permalink
Update minimal.py
Browse files Browse the repository at this point in the history
Updated minimal.py (removed test code)
  • Loading branch information
mathgeekcoder committed Jul 23, 2024
1 parent 3b5c3da commit 66f4892
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions examples/minimal.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
import highspy
import time
import networkx as nx
from random import randint

h = highspy.Highs()

(x1, x2) = h.addVariables(2, lb = -h.inf)
x1 = h.addVariable(lb = -h.inf)
x2 = h.addVariable(lb = -h.inf)

h.addConstrs(x2 - x1 >= 2,
x1 + x2 >= 0)

h.minimize(x2)



h = highspy.Highs()


G = nx.circular_ladder_graph(5).to_directed()
nx.set_edge_attributes(G, {e: {'weight': randint(1, 9)} for e in G.edges})

d = h.addBinaries(G.edges, obj=nx.get_edge_attributes(G, 'weight'))

h.addConstrs(sum(d[e] for e in G.in_edges(i)) - sum(d[e] for e in G.out_edges(i)) == 0 for i in G.nodes)

h = highspy.Highs()

ts = time.time()
perf1 = [h.addBinary() for _ in range(1000000)]
t1 = time.time() - ts
print(t1)

h = highspy.Highs()

ts = time.time()
perf2 = h.addVariables(1000000)
t2 = time.time() - ts
print(t2)

0 comments on commit 66f4892

Please sign in to comment.