Commit 49d14caa authored by Chinmay Garde's avatar Chinmay Garde

Make the midpoints test pass. Fixes incorrect Row.reverseSign

parent 20908034
......@@ -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));
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment