From a6751724df3dbaa5441a930a32308d2d3e07f4e0 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Sun, 24 Nov 2019 20:00:46 -0500
Subject: [PATCH] Create example JSON readin files

---
 main.py                        | 25 ++++++++++++++++++-------
 resources/json_files/ex_1.json |  9 +++++++++
 resources/json_files/ex_2.json | 10 ++++++++++
 resources/json_files/ex_3.json | 10 ++++++++++
 4 files changed, 47 insertions(+), 7 deletions(-)
 create mode 100644 resources/json_files/ex_1.json
 create mode 100644 resources/json_files/ex_2.json
 create mode 100644 resources/json_files/ex_3.json

diff --git a/main.py b/main.py
index 289c573..725a6fe 100644
--- a/main.py
+++ b/main.py
@@ -22,15 +22,26 @@ logger = init_logging.get_logger(__name__)
 def test_simplex():
     simplex = Simplex()
 
-    simplex._a = [
-        [1,3,1,0,0],
-        [2,2,0,1,0],
-        [3,1,0,0,1]
-    ]
-    simplex._b = [1, 1, 1, 1, 0]
-    simplex._c = [1, 1, 1, 0, 0]
+    # Read and display ex_1.json.
+    logger.info('')
+    logger.info('Reading in resources/ex_1.json.')
+    simplex.read_data_from_json('./resources/json_files/ex_1.json')
+    simplex.display_tableau()
+    logger.info('')
+
+    # Read and display ex_2.json.
+    logger.info('')
+    logger.info('Reading in resources/ex_2.json.')
+    simplex.read_data_from_json('./resources/json_files/ex_2.json')
+    simplex.display_tableau()
+    logger.info('')
 
+    # Read and display ex_3.json.
+    logger.info('')
+    logger.info('Reading in resources/ex_3.json.')
+    simplex.read_data_from_json('./resources/json_files/ex_3.json')
     simplex.display_tableau()
+    logger.info('')
 
 
 
diff --git a/resources/json_files/ex_1.json b/resources/json_files/ex_1.json
new file mode 100644
index 0000000..68ce157
--- /dev/null
+++ b/resources/json_files/ex_1.json
@@ -0,0 +1,9 @@
+{
+    "Description": "A basic simplex, consisting of only 1's and 0's for coefficients.",
+    "constraints": [
+        [1, 1, 1, 0],
+        [1, 1, 0, 1]
+    ],
+    "constants": [1, 1],
+    "objective": [1, 1, 0, 0]
+}
diff --git a/resources/json_files/ex_2.json b/resources/json_files/ex_2.json
new file mode 100644
index 0000000..bc75e9b
--- /dev/null
+++ b/resources/json_files/ex_2.json
@@ -0,0 +1,10 @@
+{
+    "Description": "A 3x3 simplex, with basic variables provided.",
+    "constraints": [
+        [1, 1, 1, 1, 0, 0],
+        [2, -1, 2, 0, 1, 0],
+        [2, 1, 0, 0, 0, 1]
+    ],
+    "constants": [5, 3, 4],
+    "objective": [2, 3, 1, 0, 0, 0]
+}
diff --git a/resources/json_files/ex_3.json b/resources/json_files/ex_3.json
new file mode 100644
index 0000000..40631a6
--- /dev/null
+++ b/resources/json_files/ex_3.json
@@ -0,0 +1,10 @@
+{
+    "Description": "Same as ex_2.json, but with basic variables not provided.",
+    "constraints": [
+        [1, 1, 1],
+        [2, -1, 2],
+        [2, 1, 0]
+    ],
+    "constants": [5, 3, 4],
+    "objective": [2, 3, 1]
+}
-- 
GitLab