Commit 3bed9686 authored by Vladislav Kiselev's avatar Vladislav Kiselev

bug with getCurrentValue fixed

parent c7a14c43
......@@ -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<keyTime)
if (forTime>=prevKey && forTime<keyTime)
{
res = flow.get(prevKey);
isFound = true;
......@@ -78,7 +79,7 @@ public class CargoFlow {
} else
prevKey = keyTime;
}
if (!isFound && forTime>prevKey)
if (!isFound && forTime >= prevKey)
res = flow.get(prevKey);
return res;
}
......@@ -123,7 +124,7 @@ public class CargoFlow {
}
public CargoFlow(String s, Map<Integer, Storage> mp, Map<Integer, Cargo> cp) {
this.flow = new HashMap<>();
this.flow = new TreeMap<>();
String[] tokens = s.split(";");
int key = Integer.parseInt(tokens[0].trim());
storage = mp.get(key);
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment