Skip to content

Commit

Permalink
все находится почти правильно, но знак неверный. когда меняю на нужны…
Browse files Browse the repository at this point in the history
…й все становится true. смотрим solve и insert
  • Loading branch information
roman-karpovich committed May 13, 2014
1 parent f85bfef commit b6bd4b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/by/bsu/coursework/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
*/
public class Logger {
public static void info(String info){
//System.out.println(info);
System.out.println(info);
}
}
9 changes: 9 additions & 0 deletions src/main/java/by/bsu/coursework/structures/Equation.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public Equation() {
rightPart=new LinkedList<>();
}

public Equation(LinkedList<EquationPart> leftPart, LinkedList<EquationPart> rightPart) {
this.leftPart=new LinkedList<>(leftPart);
this.rightPart=new LinkedList<>(rightPart);
}

public void addToLeft(EquationPart var){
leftPart.add(var);
}
Expand Down Expand Up @@ -148,4 +153,8 @@ public void insert(Commutation what){
i++;
}
}

Equation copy() {
return new Equation(this.leftPart,this.rightPart);
}
}
22 changes: 12 additions & 10 deletions src/main/java/by/bsu/coursework/structures/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ public void calculate() {
roots.add(root);
systems.add(Worker.getSystem(flow, vertices, flowIndex, alphas.get(flowIndex)));
cyclicEdges.add(cyclicEdge);

calculateCharacteristicVectors(
flowIndex,
flows,
characteristicVectors,
cyclicEdge,
spanningTree,
systems,
gettArrayInversed(flowIndex),
getpArray(flowIndex),
getdArray(flowIndex));

calculateParticleSolve(
flowIndex,
flows,
characteristicVectors,
cyclicEdge,
spanningTree,
Expand All @@ -102,15 +102,13 @@ public void calculate() {

static void calculateCharacteristicVectors(
int flowIndex,
ArrayList<LinkedList<Edge>> flows,
LinkedList<CharacteristicVector> vectors,
LinkedList<Edge> cyclicEdges,
LinkedList<Edge> spanningTree,
ArrayList<ArrayList<Equation>> systems,
List<Integer> t,
Integer[] p,
Integer[] d){
LinkedList<Edge> flow = flows.get(flowIndex);

for (int i=0; i<cyclicEdges.size(); i++){
Edge edge = cyclicEdges.get(i);
Expand All @@ -120,9 +118,12 @@ static void calculateCharacteristicVectors(
mainEdge.addTo(new Constant(1));
vector.addCommutation(mainEdge);

ArrayList<Equation> system = (ArrayList)systems.get(flowIndex).clone();
for (Equation e:system)
e.zeroRight();
ArrayList<Equation> system = new ArrayList<>();
for (Equation e:systems.get(flowIndex)){
Equation eq = e.copy();
eq.zeroRight();
system.add(eq);
}

for (Edge e:cyclicEdges){
if (!e.equals(edge)){
Expand Down Expand Up @@ -157,20 +158,21 @@ static void calculateCharacteristicVectors(

static void calculateParticleSolve(
int flowIndex,
ArrayList<LinkedList<Edge>> flows,
LinkedList<CharacteristicVector> vectors,
LinkedList<Edge> cyclicEdges,
LinkedList<Edge> spanningTree,
ArrayList<ArrayList<Equation>> systems,
List<Integer> t,
Integer[] p,
Integer[] d){
LinkedList<Edge> flow = flows.get(flowIndex);

Edge edge = new Edge(0,0);
CharacteristicVector vector = new CharacteristicVector(flowIndex,edge.toString());

ArrayList<Equation> system = (ArrayList)systems.get(flowIndex).clone();
ArrayList<Equation> system = new ArrayList<>();
for (Equation e:systems.get(flowIndex)){
system.add(e.copy());
}

for (Edge e:cyclicEdges){
Commutation tmp = new Commutation(new Variable("x",e.toString(),""+flowIndex,1));
Expand Down

0 comments on commit b6bd4b5

Please sign in to comment.