Make the midpoints test pass. Fixes incorrect Row.reverseSign

This commit is contained in:
Chinmay Garde
2015-06-25 17:07:15 -07:00
parent 20908034d5
commit 49d14caa69
3 changed files with 9 additions and 6 deletions

View File

@@ -34,7 +34,10 @@ class _Row {
cells.remove(symbol);
}
void reverseSign() => cells.forEach((s, v) => cells[s] = -v);
void reverseSign() {
constant = -constant;
cells.forEach((s, v) => cells[s] = -v);
}
void solveForSymbol(_Symbol symbol) {
assert(cells.containsKey(symbol));

View File

@@ -12,7 +12,7 @@ class Solver {
final List<_Symbol> _infeasibleRows = new List<_Symbol>();
final _Row _objective = new _Row(0.0);
_Row _artificial = new _Row(0.0);
int tick = 0;
int tick = 1;
/// Attempts to add the constraints in the list to the solver. If it cannot
/// add any for some reason, a cleanup is attempted so that either all

View File

@@ -432,13 +432,13 @@ void main() {
});
test('midpoints', () {
var left = new Param(0.0);
var right = new Param(0.0);
var mid = new Param(0.0);
var left = new Param(0.0)..name = "left";
var right = new Param(0.0)..name = "right";
var mid = new Param(0.0)..name = "mid";
Solver s = new Solver();
expect(s.addConstraint((left + right == CM(2.0) * mid) as Constraint),
expect(s.addConstraint((right + left == mid * CM(2.0)) as Constraint),
Result.success);
expect(s.addConstraint(right - left >= CM(100.0)), Result.success);
expect(s.addConstraint(left >= CM(0.0)), Result.success);