From b6c1bf304627e6a32d8899e7fd14b046e507322e Mon Sep 17 00:00:00 2001 From: Alex Birkett Date: Mon, 1 Feb 2016 23:10:18 +0100 Subject: [PATCH] Remove symbol ids Also absent from haxe port: https://github.com/Tw1ddle/haxe-kiwi/commit/300617e5c0b041ca20842056c764d728b646f801 --- src/main/java/no/birkett/kiwi/Solver.java | 16 +++++------ src/main/java/no/birkett/kiwi/Symbol.java | 35 ++--------------------- 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/main/java/no/birkett/kiwi/Solver.java b/src/main/java/no/birkett/kiwi/Solver.java index 7cfc098..c256834 100644 --- a/src/main/java/no/birkett/kiwi/Solver.java +++ b/src/main/java/no/birkett/kiwi/Solver.java @@ -37,7 +37,6 @@ public class Solver { private List infeasibleRows = new ArrayList(); private Row objective = new Row(); private Row artificial; - private long idTick = 1; /** @@ -327,11 +326,11 @@ public class Solver { case OP_LE: case OP_GE: { double coeff = constraint.getOp() == RelationalOperator.OP_LE ? 1.0 : -1.0; - Symbol slack = new Symbol(Symbol.Type.SLACK, idTick++); + Symbol slack = new Symbol(Symbol.Type.SLACK); tag.marker = slack; row.insert(slack, coeff); if (constraint.getStrength() < Strength.REQUIRED) { - Symbol error = new Symbol(Symbol.Type.ERROR, idTick++); + Symbol error = new Symbol(Symbol.Type.ERROR); tag.other = error; row.insert(error, -coeff); this.objective.insert(error, constraint.getStrength()); @@ -340,8 +339,8 @@ public class Solver { } case OP_EQ: { if (constraint.getStrength() < Strength.REQUIRED) { - Symbol errplus = new Symbol(Symbol.Type.ERROR, idTick++); - Symbol errminus = new Symbol(Symbol.Type.ERROR, idTick++); + Symbol errplus = new Symbol(Symbol.Type.ERROR); + Symbol errminus = new Symbol(Symbol.Type.ERROR); tag.marker = errplus; tag.other = errminus; row.insert(errplus, -1.0); // v = eplus - eminus @@ -349,7 +348,7 @@ public class Solver { this.objective.insert(errplus, constraint.getStrength()); this.objective.insert(errminus, constraint.getStrength()); } else { - Symbol dummy = new Symbol(Symbol.Type.DUMMY, idTick++); + Symbol dummy = new Symbol(Symbol.Type.DUMMY); tag.marker = dummy; row.insert(dummy); } @@ -404,7 +403,7 @@ public class Solver { // Create and add the artificial variable to the tableau - Symbol art = new Symbol(Symbol.Type.SLACK, idTick++); + Symbol art = new Symbol(Symbol.Type.SLACK); rows.put(art, new Row(row)); this.artificial = new Row(row); @@ -638,8 +637,7 @@ public class Solver { if (vars.containsKey(variable)) { symbol = vars.get(variable); } else { - symbol = new Symbol(Symbol.Type.EXTERNAL, idTick++); - symbol.setVariableName(variable.getName()); + symbol = new Symbol(Symbol.Type.EXTERNAL); vars.put(variable, symbol); } return symbol; diff --git a/src/main/java/no/birkett/kiwi/Symbol.java b/src/main/java/no/birkett/kiwi/Symbol.java index a851d8b..26e9892 100644 --- a/src/main/java/no/birkett/kiwi/Symbol.java +++ b/src/main/java/no/birkett/kiwi/Symbol.java @@ -14,48 +14,17 @@ public class Symbol { } private Type type; - private long id; - private String variableName; public Symbol() { - this(Type.INVALID, 0); + this(Type.INVALID); } - public Symbol(Type type, long id) { + public Symbol(Type type) { this.type = type; - this.id = id; } public Type getType() { return type; } - public void setType(Type type) { - this.type = type; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getVariableName() { - return variableName; - } - - public void setVariableName(String variableName) { - this.variableName = variableName; - } - - boolean lessThan(Symbol other) { - return this.id < other.getId(); - } - - boolean equals(Symbol other) { - return this.id == other.getId(); - } - }