From fc20124000c4af20e4c711e5c158317ae8e331f8 Mon Sep 17 00:00:00 2001 From: Johan Enell Date: Tue, 9 May 2023 16:08:32 +0200 Subject: [PATCH] feat: penalty for charge discharge periods that doesn't change soc (#36) --- src/fitness.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fitness.js b/src/fitness.js index 1c91528..952c0c0 100644 --- a/src/fitness.js +++ b/src/fitness.js @@ -203,8 +203,13 @@ const calculatePeriodScore = ( const fitnessFunction = (props) => (phenotype) => { let cost = 0 + let averagePrice = props.input.reduce((acc, cur) => acc + cur.importPrice, 0) / props.input.length for (const period of allPeriodsGenerator(props, phenotype)) { + let periodScore = period.cost + if (period.activity != 0 && period.charge == 0) { + periodScore += averagePrice * period.duration / 60 + } cost -= period.cost }