From 3bed9686dc9d8c0dec7ac8db9ccd954612bcf521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=81=D0=B5=D0=BB=D1=91=D0=B2=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2?= Date: Mon, 19 Nov 2018 23:05:38 +0300 Subject: [PATCH] bug with getCurrentValue fixed --- src/inport/CargoFlow.java | 9 +++++---- src/inport/ConversionUtil.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/inport/CargoFlow.java b/src/inport/CargoFlow.java index cdc5459..b266584 100644 --- a/src/inport/CargoFlow.java +++ b/src/inport/CargoFlow.java @@ -7,6 +7,7 @@ package inport; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.TreeMap; /** * @@ -59,7 +60,7 @@ public class CargoFlow { public CargoFlow(Storage storage, Cargo cargo) { this.storage = storage; this.cargo = cargo; - this.flow = new HashMap<>(); + this.flow = new TreeMap<>(); } public double getCurrentValue(double forTime) @@ -70,7 +71,7 @@ public class CargoFlow { double prevKey = -1.0; for (Double keyTime : keyTimes) { - if (forTime>prevKey && forTime=prevKey && forTimeprevKey) + if (!isFound && forTime >= prevKey) res = flow.get(prevKey); return res; } @@ -123,7 +124,7 @@ public class CargoFlow { } public CargoFlow(String s, Map mp, Map cp) { - this.flow = new HashMap<>(); + this.flow = new TreeMap<>(); String[] tokens = s.split(";"); int key = Integer.parseInt(tokens[0].trim()); storage = mp.get(key); diff --git a/src/inport/ConversionUtil.java b/src/inport/ConversionUtil.java index d440587..18e499a 100644 --- a/src/inport/ConversionUtil.java +++ b/src/inport/ConversionUtil.java @@ -465,7 +465,7 @@ public class ConversionUtil { int storageN = storNById.get(flow.getStorage().getId()); int cargoN = cargoNById.get(flow.getCargo().getId()); for (int i = 1; i < n_intervals + 2; i++) { - cargoFlows.get(storageN + movingObjects.size()).get(i).set(cargoN, (int)flow.getCurrentValue(i)); + cargoFlows.get(storageN + movingObjects.size()).get(i).set(cargoN, (int)flow.getCurrentValue(i - 0.1)); } } writer.write("cargo_flows = array3d(1..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types, ["); @@ -501,7 +501,7 @@ public class ConversionUtil { LoadingTemplate op = (LoadingTemplate) operationTemplates.get(i); int storageN = storNById.get(op.getStorage().getId()); int shipN = mObjToN.apply(op.getLoader()); - int cargoN = 0; // TODO в TaskCase пока не реализовано, пересмотреть. + int cargoN = cargoNById.get(op.getStorage().getCargo().getId());// TODO в TaskCase пока не реализовано, пересмотреть. loadingOpDelta.add(-(int)op.getIntensity()); loadingOpN.add(i); -- GitLab