|
@@ -38,7 +38,7 @@ func ProductionPlanner(payload *models.Payload) []interface{} {
|
|
|
wind, _ := fuels["wind(%)"].(json.Number).Float64()
|
|
wind, _ := fuels["wind(%)"].(json.Number).Float64()
|
|
|
for _, plant := range payload.Powerplants {
|
|
for _, plant := range payload.Powerplants {
|
|
|
if *plant.Type == "windturbine" {
|
|
if *plant.Type == "windturbine" {
|
|
|
- *plant.Pmax = *plant.Pmax * wind / 100
|
|
|
|
|
|
|
+ *plant.Pmax = math.Round(*plant.Pmax * wind / 10) / 10
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
fuels["wind(%)"] = json.Number(0)
|
|
fuels["wind(%)"] = json.Number(0)
|
|
@@ -64,17 +64,24 @@ func ProductionPlanner(payload *models.Payload) []interface{} {
|
|
|
}
|
|
}
|
|
|
fuel, _ := fuels[powerplantFuel[*plant.Type]].(json.Number).Float64()
|
|
fuel, _ := fuels[powerplantFuel[*plant.Type]].(json.Number).Float64()
|
|
|
if *plant.Pmin < remainingLoad {
|
|
if *plant.Pmin < remainingLoad {
|
|
|
- usedP := math.Min(remainingLoad, *plant.Pmax)
|
|
|
|
|
- load += usedP
|
|
|
|
|
- cost = append(cost, usedP / *plant.Efficiency * fuel)
|
|
|
|
|
- res = append(res, map[string]interface{}{
|
|
|
|
|
- "name": plant.Name,
|
|
|
|
|
- "p": usedP,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if *plant.Pmax != 0 {
|
|
|
|
|
+ usedP := math.Min(remainingLoad, *plant.Pmax)
|
|
|
|
|
+ load += usedP
|
|
|
|
|
+ cost = append(cost, usedP / *plant.Efficiency * fuel)
|
|
|
|
|
+ res = append(res, map[string]interface{}{
|
|
|
|
|
+ "name": plant.Name,
|
|
|
|
|
+ "p": usedP,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- altRes := make([]interface{}, 0)
|
|
|
|
|
- altCost := make([]float64, 0)
|
|
|
|
|
- copy(altRes, res)
|
|
|
|
|
|
|
+ altRes := make([]interface{}, len(res))
|
|
|
|
|
+ for i, re := range res {
|
|
|
|
|
+ altRes[i] = map[string]interface{}{
|
|
|
|
|
+ "name": re.(map[string]interface{})["name"],
|
|
|
|
|
+ "p": re.(map[string]interface{})["p"],
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ altCost := make([]float64, len(cost))
|
|
|
copy(altCost, cost)
|
|
copy(altCost, cost)
|
|
|
loadToRemove := *plant.Pmin - remainingLoad
|
|
loadToRemove := *plant.Pmin - remainingLoad
|
|
|
for loadToRemove > 0 {
|
|
for loadToRemove > 0 {
|
|
@@ -90,9 +97,9 @@ func ProductionPlanner(payload *models.Payload) []interface{} {
|
|
|
}
|
|
}
|
|
|
altRes = append(altRes, map[string]interface{}{
|
|
altRes = append(altRes, map[string]interface{}{
|
|
|
"name": *plant.Name,
|
|
"name": *plant.Name,
|
|
|
- "p": *plant.Pmax,
|
|
|
|
|
|
|
+ "p": *plant.Pmin,
|
|
|
})
|
|
})
|
|
|
- altCost = append(altCost, *plant.Pmax / *plant.Efficiency * fuel)
|
|
|
|
|
|
|
+ altCost = append(altCost, *plant.Pmin / *plant.Efficiency * fuel)
|
|
|
resToCompare = append(resToCompare, altRes)
|
|
resToCompare = append(resToCompare, altRes)
|
|
|
costToCompare = append(costToCompare, altCost)
|
|
costToCompare = append(costToCompare, altCost)
|
|
|
}
|
|
}
|