Skip to content

Commit

Permalink
Created new branch with new PR to avoid ugly rebase issue.
Browse files Browse the repository at this point in the history
Major highspy update:
* changed `highs_linear_expression` to be immutable by default
* improved callback support
* improved test coverage (99%)
* performance and usability enhancements
* Support `__iadd__`, `__imul__`, etc.
* Updated chain comparison support in immutable setting
* `h.val()` can take `highs_linear_expression`
* `expr == [lb,ub]` -> `lb <= expr <= ub` syntax
* `qsum`
* added pretty print `__repr__` and `__str__`
* added KeyboardInterrupt support
* added user interrupt
* fixed slicing issues with numpy and highs
* added `resetGlobalScheduler`
* released GIL for `Presolve`
* fixed issues with deadlock on Windows
* fixed MIP solution callback issue
* support `getExpr` that creates a `highs_linear_expression` from existing row

Should address multiple issues: ERGO-Code#1865, ERGO-Code#1882, ERGO-Code#1888, ERGO-Code#1892, ERGO-Code#1903, ERGO-Code#1904, and perhaps ERGO-Code#1905
  • Loading branch information
mathgeekcoder committed Sep 16, 2024
1 parent d95502b commit 370156f
Show file tree
Hide file tree
Showing 4 changed files with 2,547 additions and 376 deletions.
12 changes: 6 additions & 6 deletions examples/nqueens.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
h = highspy.Highs()
h.silent()

x = np.reshape(h.addBinaries(N*N), (N, N))
x = h.addBinaries(N, N)

h.addConstrs(sum(x[i,:]) == 1 for i in range(N)) # each row has exactly one queen
h.addConstrs(sum(x[:,j]) == 1 for j in range(N)) # each col has exactly one queen
h.addConstrs(h.qsum(x[i,:]) == 1 for i in range(N)) # each row has exactly one queen
h.addConstrs(h.qsum(x[:,j]) == 1 for j in range(N)) # each col has exactly one queen

y = np.fliplr(x)
h.addConstrs(x.diagonal(k).sum() <= 1 for k in range(-N + 1, N)) # each diagonal has at most one queen
h.addConstrs(y.diagonal(k).sum() <= 1 for k in range(-N + 1, N)) # each 'reverse' diagonal has at most one queen
h.addConstrs(h.qsum(x.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each diagonal has at most one queen
h.addConstrs(h.qsum(y.diagonal(k)) <= 1 for k in range(-N + 1, N)) # each 'reverse' diagonal has at most one queen

h.solve()
sol = np.array(h.vals(x))
sol = h.vals(x)

print('Queens:')

Expand Down
Loading

0 comments on commit 370156f

Please sign in to comment.