Skip to content

Commit

Permalink
Runs on command line user input
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan-CS committed Mar 27, 2021
1 parent 1671240 commit 11e841e
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 123 deletions.
10 changes: 10 additions & 0 deletions .idea/artifacts/Equations_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions Equations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
*** Equations for an SIR model on a Toast Graph ***

0: 0 1 1 1
1: 1 0 1 0
2: 1 1 0 1
3: 1 0 1 0
Numbers of equations of each size: [8, 10, 16, 8]

[〈S3〉] = - β〈S3 I0〉- β〈S3 I2〉
[〈S2〉] = - β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈S1〉] = - β〈S1 I0〉- β〈S1 I2〉
[〈S0〉] = - β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I3〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉
[〈I2〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉
[〈I1〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉
[〈I0〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉
[〈I3〉, 〈S2〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I3〉, 〈S0〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I2〉, 〈S3〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S3 I0〉- β〈S3 I2〉
[〈I2〉, 〈S1〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S1 I0〉- β〈S1 I2〉
[〈I2〉, 〈S0〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I1〉, 〈S2〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I1〉, 〈S0〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I0〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S3 I0〉- β〈S3 I2〉
[〈I0〉, 〈S2〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I0〉, 〈S1〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S1 I0〉- β〈S1 I2〉
[〈I3〉, 〈S0〉, 〈S2〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I3〉, 〈S0〉, 〈S1〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S1 I0〉- β〈S1 I2〉
[〈I2〉, 〈S0〉, 〈S3〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I2〉, 〈S0〉, 〈S1〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S1 I0〉- β〈S1 I2〉
[〈I2〉, 〈I3〉, 〈S0〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉+ γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I1〉, 〈S2〉, 〈S3〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I1〉, 〈S0〉, 〈S3〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I1〉, 〈S0〉, 〈S2〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I1〉, 〈I2〉, 〈S3〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S3 I0〉- β〈S3 I2〉
[〈I1〉, 〈I2〉, 〈S0〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I0〉, 〈S2〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I0〉, 〈S1〉, 〈S2〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S1 I0〉- β〈S1 I2〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I0〉, 〈I3〉, 〈S2〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I0〉, 〈I2〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S3 I0〉- β〈S3 I2〉
[〈I0〉, 〈I2〉, 〈S1〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S1 I0〉- β〈S1 I2〉
[〈I0〉, 〈I1〉, 〈S2〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I3〉, 〈S0〉, 〈S1〉, 〈S2〉] = γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S1 I0〉- β〈S1 I2〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉
[〈I2〉, 〈I3〉, 〈S0〉, 〈S1〉] = γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉+ γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S1 I0〉- β〈S1 I2〉
[〈I1〉, 〈S0〉, 〈S2〉, 〈S3〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I1〉, 〈I2〉, 〈S0〉, 〈S3〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I1〉, 〈I2〉, 〈I3〉, 〈S0〉] = γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉+ γ〈S3 I0〉+ γ〈S3 I2〉- γ〈I3〉- β〈S0 I1〉- β〈S0 I2〉- β〈S0 I3〉
[〈I0〉, 〈S1〉, 〈S2〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉- β〈S1 I0〉- β〈S1 I2〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I0〉, 〈I1〉, 〈S2〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉- β〈S2 I0〉- β〈S2 I1〉- β〈S2 I3〉- β〈S3 I0〉- β〈S3 I2〉
[〈I0〉, 〈I1〉, 〈I2〉, 〈S3〉] = γ〈S0 I1〉+ γ〈S0 I2〉+ γ〈S0 I3〉- γ〈I0〉+ γ〈S1 I0〉+ γ〈S1 I2〉- γ〈I1〉+ γ〈S2 I0〉+ γ〈S2 I1〉+ γ〈S2 I3〉- γ〈I2〉- β〈S3 I0〉- β〈S3 I2〉
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: io.github.ethankelly.Main

54 changes: 0 additions & 54 deletions src/io/github/ethankelly/Equations.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,58 +78,4 @@ public static List<String> generateEquations(Tuple tuples) {

return equations;
}

public static void main(String[] args) throws FileNotFoundException {
PrintStream o = new PrintStream("TLTEquations.txt");
System.setOut(o);

char[] states = new char[]{'S', 'I', 'R', 'P'};
// TRIANGLE
Graph triangle = new Graph(3);
triangle.addEdge(0, 1);
triangle.addEdge(1, 2);
triangle.addEdge(2, 0);
Tuple triangleNE = new Tuple(triangle, states);

System.out.println(" *** TRIANGLE GRAPH ***\n\n" + triangle + "Numbers of equations of each size: "
+ Arrays.toString(triangleNE.findNumbers(triangleNE.getTuples())) + "\n");
Equations.generateEquations(triangleNE).forEach(System.out::println);

// LOLLIPOP
Graph lollipop = new Graph(4);
lollipop.addEdge(0, 1);
lollipop.addEdge(0, 2);
lollipop.addEdge(0, 3);
lollipop.addEdge(2, 3);
Tuple lollipopNE = new Tuple(lollipop, states);

System.out.println("\n *** LOLLIPOP GRAPH ***\n\n" + lollipop + "Numbers of equations of each size: "
+ Arrays.toString(lollipopNE.findNumbers(lollipopNE.getTuples())) + "\n");
Equations.generateEquations(lollipopNE).forEach(System.out::println);

// TOAST
Graph toast = new Graph(4);
toast.addEdge(0, 1);
toast.addEdge(0, 2);
toast.addEdge(0, 3);
toast.addEdge(1, 2);
toast.addEdge(2, 3);
Tuple toastNE = new Tuple(toast, states);

System.out.println("\n *** TOAST GRAPH ***\n\n" + toast + "Numbers of equations of each size: "
+ Arrays.toString(toastNE.findNumbers(toastNE.getTuples())) + "\n");
Equations.generateEquations(toastNE).forEach(System.out::println);

// Creating another File object that represents the disk file and assign to output stream
PrintStream er = new PrintStream("ErdosRenyiTest.txt");
System.setOut(er);

// ERDOS-RENYI
Graph erdosRenyi = GraphGenerator.erdosRenyi(5, 0.5);
Tuple erdosRenyiNE = new Tuple(erdosRenyi, states);

System.out.println(" *** ERDOS-RENYI GRAPH ***\n\n" + erdosRenyi + "Numbers of equations of each size: "
+ Arrays.toString(erdosRenyiNE.findNumbers(erdosRenyiNE.getTuples())) + "\n");
Equations.generateEquations(erdosRenyiNE).forEach(System.out::println);
}
}
14 changes: 13 additions & 1 deletion src/io/github/ethankelly/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @author <a href="mailto:[email protected]">Ethan Kelly</a>
*/
public class Graph {

private String name;
private int numVertices;
private int numEdges;
private boolean[][] adjMatrix;
Expand All @@ -33,10 +35,11 @@ public class Graph {
*
* @param numVertices the number of vertices to create in the graph.
*/
public Graph(int numVertices) {
public Graph(int numVertices, String name) {
this.numVertices = numVertices;
this.adjMatrix = new boolean[numVertices][numVertices];
this.transmissionMatrix = new int[numVertices][numVertices];
this.name = name;
}

/**
Expand Down Expand Up @@ -244,4 +247,13 @@ public int[][] getTransmissionMatrix() {
public void setTransmissionMatrix(int[][] transmissionMatrix) {
this.transmissionMatrix = transmissionMatrix;
}

public Graph setName(String name) {
this.name = name;
return this;
}

public String getName() {
return this.name;
}
}
Loading

0 comments on commit 11e841e

Please sign in to comment.