From 93ae31ba64dbccb7c0e17f6e124de57001e8a1a4 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 14 Oct 2021 08:22:43 +0200
Subject: [PATCH] hybrid strategy: calculation of gearshift penalty - if score
 is negative, multiply with penalty (instead of dividing) to get a worse
 rating

---
 .../VectoCommon/Models/HybridStrategyResponse.cs    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs b/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs
index b2a328ef07..980076d4b3 100644
--- a/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs
+++ b/VectoCommon/VectoCommon/Models/HybridStrategyResponse.cs
@@ -44,9 +44,16 @@ namespace TUGraz.VectoCommon.Models {
 		public IResponse Response { get; set; }
 
 
-		public double Score =>
-			(FuelCosts + EquivalenceFactor * (BatCosts + ICEStartPenalty1) * SoCPenalty + ICEStartPenalty2 +
-			RampUpPenalty) / GearshiftPenalty;
+		public double Score
+		{
+			get
+			{
+				var cost = (FuelCosts + EquivalenceFactor * (BatCosts + ICEStartPenalty1) * SoCPenalty + ICEStartPenalty2 +
+				RampUpPenalty);
+				var gearshift = cost.IsSmaller(0) ? GearshiftPenalty : 1 / GearshiftPenalty;
+				return cost * gearshift;
+			}
+		}
 
 		public double FuelCosts { get; set; }
 
-- 
GitLab