Commit Graph

72 Commits

Author SHA1 Message Date
Michael Neumann
a870cb4cc7 MarkMatrix - Refactor 2019-04-07 14:32:22 +02:00
Michael Neumann
ec53b07747 Get rid of MarkMatrix trait again 2019-04-07 13:34:37 +02:00
Michael Neumann
10ec98b791 Fix bug in MarkMatrixBitArray 2019-04-07 13:24:48 +02:00
Michael Neumann
881bb16f65 Use FixedBitSet#ones() iterator
Improves performance by about 5%
2019-04-07 12:18:56 +02:00
Michael Neumann
841fc0c4da Use FixedBitSet#ones() iterator and rename function again
Improves performance by about 10%.
2019-04-07 12:08:38 +02:00
Michael Neumann
aa33d76281 Rename function 2019-04-07 12:00:00 +02:00
Michael Neumann
bf353be676 Invert logic in Coverage "matrix"
The idea here is to use FixedBitSet#ones() iterator in the next commit.
2019-04-07 11:55:18 +02:00
Michael Neumann
8adec9a9ee Coverage: rename {rows, columns} -> covered_{rows, columns} 2019-04-07 11:23:17 +02:00
Michael Neumann
16bc0a7cbd Refactor Coverage 2019-04-07 11:19:54 +02:00
Michael Neumann
44847c04e1 Breaking API - Return Vec<Position> from solve_assignment()
Also simplify some test cases.
2019-04-07 11:02:57 +02:00
Michael Neumann
9ec92b7bff Refactor - breaking changes to API
* Rename col -> column in parameters and method names.

* Replace (usize, usize) by struct Position. This makes it more explicit
  what the row and column index is.

* Make MarkMatrix a trait and provide two implementation
  MarkMatrixByteArray and MarkMatrixBitArray.

* Add solve_assignment_generic which can be used with an alternative
  MarkMatrix implementation
2019-04-07 10:35:52 +02:00
Michael Neumann
9be159c4fd Use criterion for benchmarks
We no longer need nightly rust to run benchmarks (or tests).
2019-04-06 20:36:00 +02:00
Michael Neumann
c1b4498a65 Rust rustfmt 2019-04-06 20:10:57 +02:00
Michael Neumann
9ef1acacd8 Use WeightNum into separate module 2019-04-06 20:10:41 +02:00
Michael Neumann
2824a1123f Changes for Cargo edition 2018 2019-04-06 20:05:22 +02:00
Michael Neumann
73910f7dde Return Error enum instead of static str 2018-01-30 15:16:47 +01:00
Michael Neumann
c7dd965658 Get rid of panics. Return Result instead 2018-01-30 15:12:51 +01:00
Michael Neumann
46599ee62a Reformat source code using "cargo fmt" 2018-01-30 15:09:27 +01:00
Michael Killough
d3e2c23415 Support for disallowed assignments.
Add support for disallowed assignments, and include a check to avoid
attempting to solve unsolvable matrices (where a row only has disallowed
values).

For now only allow `f32`/`f64`, as we can use `INFINITY` to encode a
disallowed assignment.

This is a re-implementation of most of bmc/munkres#20, but is missing
the changes to `step6`, which attempt to detect when we're not making
progress. I couldn't implement this without regressing performance and I
am not sure they add much given we're checking `is_solvable()` before
attempting to solve.
2017-11-07 12:21:19 +00:00
Andrii Dmytrenko
ad0d85a2c4 Remove square_matrix module 2017-11-07 11:26:00 +00:00
Andrii Dmytrenko
092818ab88 Use ndarray to implement SquareMatrix 2017-10-16 16:34:14 +01:00
Michael Neumann
b34aa6b2eb Remove unstable feature zero_one (Zero trait)
This allows this library to be build with a stable Rust release.
2016-07-16 13:40:13 +02:00
Michael Neumann
9e72192398 Slightly improve performance by reusing path 2016-02-27 22:43:08 +01:00
Michael Neumann
ba128c0c93 Add is_zero() to trait WeightNum 2016-02-27 22:36:04 +01:00
Michael Neumann
ed7c417013 Remove benchmarks with 1000 or 2000. It's too slow 2016-02-27 22:30:53 +01:00
Michael Neumann
7ab7269164 Some minor changes 2016-02-27 22:30:06 +01:00
Michael Neumann
92b390ce88 Add some more test cases which detected the bug fix in
51c5b7638f
2016-02-27 20:46:35 +01:00
Michael Neumann
7feb1fcdaf unmark() need not be public. 2016-02-27 20:45:46 +01:00
Michael Neumann
a3a79cc599 Add some more debug assertions 2016-02-27 20:45:11 +01:00
Michael Neumann
51c5b7638f BUG FIX! If we cover a row and column, we have to leave the column
loop.

This degrades performance by a LOT!
2016-02-27 20:44:02 +01:00
Michael Neumann
75a5f20802 Add test case for WeightMatrix 2016-02-27 19:30:33 +01:00
Michael Neumann
999470f6ed Add test cases for SquareMatrix 2016-02-27 19:21:08 +01:00
Michael Neumann
f47fb4eb32 Use associated type 2015-11-29 17:18:55 +01:00
Michael Neumann
482bf47cd0 Introduce trait Weights 2015-11-29 17:14:50 +01:00
Michael Neumann
b69aa2c942 rustfmt 2015-11-29 16:31:58 +01:00
Michael Neumann
2eb5f8994f Move WeightMatrix into it's own module 2015-11-29 16:30:27 +01:00
Michael Neumann
98b367d434 Use more compact representation of Mark 2015-11-29 16:24:36 +01:00
Michael Neumann
883165b0d5 Refactor 2015-11-29 16:18:19 +01:00
Michael Neumann
5b5849cd40 Operating directly on bit-representation is not much faster. 2015-11-29 16:10:34 +01:00
Michael Neumann
1a15e8f7ac Refactor 2015-11-29 15:45:26 +01:00
Michael Neumann
856ea59d70 Improve performance by replacing bit_vec with fixedbitset.
Before:
    test bench_solve_100  ... bench:      53,365 ns/iter (+/- 651)
    test bench_solve_1000 ... bench:   5,864,809 ns/iter (+/- 102,059)
    test bench_solve_2000 ... bench:  34,347,333 ns/iter (+/- 200,639)

After:

    test bench_solve_100  ... bench:      41,574 ns/iter (+/- 765)
    test bench_solve_1000 ... bench:   4,693,452 ns/iter (+/- 189,201)
    test bench_solve_2000 ... bench:  29,954,973 ns/iter (+/- 438,573)
2015-11-29 15:03:57 +01:00
Michael Neumann
c61d7152a3 Refactor a bit 2015-11-29 14:53:51 +01:00
Michael Neumann
a9bf86e22a Only require PartialOrd, not Ord and Eq. This enables us to use floats as weights. 2015-10-30 13:07:05 +01:00
Michael Neumann
7abc850887 Add WeightMatrix::from_fn() 2015-10-30 12:51:05 +01:00
Michael Neumann
188dc61817 Fix warning 2015-10-30 10:27:06 +01:00
Michael Neumann
4ee267acc5 rustfmt 2015-10-26 00:12:54 +01:00
Michael Neumann
4812071ec3 Add TODO 2015-10-20 23:31:44 +02:00
Michael Neumann
e4f3d74ad6 Rename benchmarks 2015-10-20 23:31:21 +02:00
Michael Neumann
7177a250e5 Hide mark_matrix::Mark 2015-10-20 13:47:54 +02:00
Michael Neumann
39fc8be008 Use an owned slice instead of Vec.
We never going to modify the shape of the matrix.
2015-10-20 13:38:15 +02:00