From 3f04e4cc4c3d7902e0d6d4fe89cca0d92f575625 Mon Sep 17 00:00:00 2001
From: Renan DelValle <rdelval1@binghamton.edu>
Date: Tue, 3 Jan 2017 18:10:05 -0500
Subject: [PATCH] Minor fixes. Updated the README.

---
 README.md                       | 20 ++++++++++++++++----
 schedulers/bpswClassMapWatts.go | 12 +++++++-----
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 7b3cd87..f50fbc7 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,9 @@ To Do:
    Possible to setup the constants at runtime based on the environment?
 
 
-**Requires Performance-Copilot tool pmdumptext to be installed on the
-machine on which electron is launched for logging to work**
+**Requires [Performance Co-Pilot](http://pcp.io/) tool pmdumptext to be installed on the
+machine on which electron is launched for logging to work and PCP collector agents installed
+on the Mesos Agents**
 
 
 How to run (Use the --help option to get information about other command-line options):
@@ -37,7 +38,13 @@ Workload schema:
       "watts": 50,
       "image": "gouravr/minife:v5",
       "cmd": "cd src && mpirun -np 1 miniFE.x -nx 100 -ny 100 -nz 100",
-      "inst": 9
+      "inst": 9,
+      "class_to_watts" : {
+          "A": 30.2475289996,
+          "B": 35.6491229228,
+          "C": 24.0476734352
+       }
+
    },
    {
       "name": "dgemm",
@@ -46,7 +53,12 @@ Workload schema:
       "watts": 50,
       "image": "gouravr/dgemm:v2",
       "cmd": "/./mt-dgemm 1024",
-      "inst": 9
+      "inst": 9,
+      "class_to_watts" : {
+          "A": 35.2475289996,
+          "B": 25.6491229228,
+          "C": 29.0476734352
+       }
    }
 ]
 ```
diff --git a/schedulers/bpswClassMapWatts.go b/schedulers/bpswClassMapWatts.go
index e4b0209..5307807 100644
--- a/schedulers/bpswClassMapWatts.go
+++ b/schedulers/bpswClassMapWatts.go
@@ -144,7 +144,7 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
 
 		tasks := []*mesos.TaskInfo{}
 
-		offer_cpu, offer_ram, offer_watts := OfferAgg(offer)
+		offerCPU, offerRAM, offerWatts := OfferAgg(offer)
 
 		taken := false
 		totalWatts := 0.0
@@ -168,9 +168,11 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
 					}
 				}
 				// Does the task fit
-				if (s.ignoreWatts || offer_watts >= (totalWatts+task.ClassToWatts[nodeClass])) &&
-					(offer_cpu >= (totalCPU + task.CPU)) &&
-					(offer_ram >= (totalRAM + task.RAM)) {
+				// OR lazy evaluation. If ignore watts is set to true, second statement won't
+				// be evaluated.
+				if (s.ignoreWatts || (offerWatts >= (totalWatts+task.ClassToWatts[nodeClass]))) &&
+					(offerCPU >= (totalCPU + task.CPU)) &&
+					(offerRAM >= (totalRAM + task.RAM)) {
 
 					fmt.Println("Watts being used: ", task.ClassToWatts[nodeClass])
 					taken = true
@@ -194,7 +196,7 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
 						}
 					}
 				} else {
-					break // Continue on to next offer
+					break // Continue on to next task
 				}
 			}
 		}