diff --git a/src/constraints/conversion_2.mzn b/src/constraints/conversion_2.mzn index 2bfa195de2c5f598e04acc5c4d2350968391d95c..2bee6aeef3365f1902216d136679ec497c023310 100644 --- a/src/constraints/conversion_2.mzn +++ b/src/constraints/conversion_2.mzn @@ -301,37 +301,37 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац % Грузообработка. int : n_cargo_types; - int : n_obj_with_storage; - array [0..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of var int : storage_used_volume; % Первые n_moving_obj соответствуют наполненности соответствующих движущихся объектов. + int : n_all_storage_sections; + array [0..n_all_storage_sections, 0..(n_intervals + 1)] of var int : storage_used_volume; - constraint forall (t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) (storage_used_volume[0, t, cargo] = 0); % Фиктивный объект. + constraint forall (t in 0..(n_intervals + 1)) (storage_used_volume[0, t] = 0); % Фиктивный объект. % Ограничения на вместимость. - array [0..n_obj_with_storage] of int : max_storage_vol; + array [0..n_all_storage_sections] of int : max_storage_vol; % Максимальный объём. - constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1)) ( - sum (cargo in 1..n_cargo_types) (storage_used_volume[storage, t, cargo]) <= max_storage_vol[storage] + constraint forall (storage in 1..n_all_storage_sections, t in 0..(n_intervals + 1)) ( + (storage_used_volume[storage, t]) <= max_storage_vol[storage] ); % Неотрицательность объёма. - constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) ( - 0 <= storage_used_volume[storage, t, cargo] + constraint forall (storage in 1..n_all_storage_sections, t in 0..(n_intervals + 1)) ( + 0 <= storage_used_volume[storage, t] ); % Ограничения на граничные значения. - array [0..n_obj_with_storage, 0..n_cargo_types] of int : initial_storage_vol; - array [0..n_obj_with_storage, 0..n_cargo_types] of int : final_storage_vol; + array [0..n_all_storage_sections] of int : initial_storage_vol; + array [0..n_all_storage_sections] of int : final_storage_vol; - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) ( % Initial values. - storage_used_volume[storage, 0, cargo] = initial_storage_vol[storage, cargo] + constraint forall (storage in 1..n_all_storage_sections) ( % Initial values. + storage_used_volume[storage, 0] = initial_storage_vol[storage] ); - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types % Final values. - where final_storage_vol[storage, cargo] >= 0) ( - storage_used_volume[storage, n_intervals + 1, cargo] = final_storage_vol[storage, cargo] + constraint forall (storage in 1..n_all_storage_sections % Final values. + where final_storage_vol[storage] >= 0) ( + storage_used_volume[storage, n_intervals + 1] = final_storage_vol[storage] ); % Изменение грузов в хранилищах. - array [0..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of int : cargo_flows; + array [0..n_all_storage_sections, 0..(n_intervals + 1)] of int : cargo_flows; int : n_loading_op; @@ -339,21 +339,21 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац array [0..n_operations] of int : loading_op_abs_delta; array [0..n_operations] of {1, -1} : loading_op_direction; - array [0..n_operations] of 1..n_obj_with_storage : operations_main_stor; - array [0..n_operations] of 1..n_obj_with_storage : operations_secondary_stor; + array [0..n_operations] of 1..n_all_storage_sections : operations_main_stor; + array [0..n_operations] of 1..n_all_storage_sections : operations_secondary_stor; array [0..n_operations] of 1..n_cargo_types : operations_cargo_t; array [1..n_loading_op] of int : loading_op_delta; array [1..n_loading_op] of {1, -1} : loading_op_local_direction; array [1..n_loading_op] of 1..n_operations : loading_op_n; % Номера среди общего списка операций. - array [1..n_obj_with_storage, 1..n_cargo_types] of set of 1..n_loading_op : involved_operations; + array [1..n_all_storage_sections] of set of 1..n_loading_op : involved_operations; - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types, t in 1..(n_intervals + 1)) ( - storage_used_volume[storage, t, cargo] = ( - storage_used_volume[storage, t - 1, cargo] + - cargo_flows[storage, t, cargo] + - sum (inv_op in involved_operations[storage, cargo]) ( + constraint forall (storage in 1..n_all_storage_sections, t in 1..(n_intervals + 1)) ( + storage_used_volume[storage, t] = ( + storage_used_volume[storage, t - 1] + + cargo_flows[storage, t] + + sum (inv_op in involved_operations[storage]) ( loading_op_delta[inv_op] * op_status[loading_op_n[inv_op], t] ) @@ -427,15 +427,14 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ) /\ % Если это операция пришвартовки, то в этот интервал % причал должен быть свободным. ((not is_moving_operation[op]) -> ( - let {1..n_obj_with_storage : m_stor = operations_main_stor[op]; - 1..n_obj_with_storage : s_stor = operations_secondary_stor[op]; - 1..n_cargo_types : cargo = operations_cargo_t[op]; - int : delta = loading_op_delta_of_main_obj[op]; + let {1..n_all_storage_sections : m_stor = operations_main_stor[op]; + 1..n_all_storage_sections : s_stor = operations_secondary_stor[op]; + int : delta = loading_op_delta_of_main_obj[op]; } in - (storage_used_volume[m_stor, t, cargo] + delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[m_stor, t, c])) + delta <= max_storage_vol[m_stor]) /\ - (storage_used_volume[s_stor, t, cargo] - delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[s_stor, t, c])) - delta <= max_storage_vol[s_stor]) + (storage_used_volume[m_stor, t] + delta >= 0) /\ + (storage_used_volume[m_stor, t] + delta <= max_storage_vol[m_stor]) /\ + (storage_used_volume[s_stor, t] - delta >= 0) /\ + (storage_used_volume[s_stor, t] - delta <= max_storage_vol[s_stor]) )) /\ % Если это операция грузообработки, то она не выведет % объём берегового хранилища и хранилища судна за % границы дозволенного. diff --git a/src/constraints/conversion_2_with_partial_cargo_operations.mzn b/src/constraints/conversion_2_with_partial_cargo_operations.mzn index cfcaaf71a9c9fe836e4fa0568533d166a5d03fb4..9c86594df798524ed0b138e7e1586fb040264e68 100644 --- a/src/constraints/conversion_2_with_partial_cargo_operations.mzn +++ b/src/constraints/conversion_2_with_partial_cargo_operations.mzn @@ -81,7 +81,6 @@ array [0..n_moving_obj, 0..n_operations] of bool : moving_op_of_obj; ); array [1..n_locations] of 0..n_locations : twin_location = [i - 1 + (i mod 2) * 2 | i in 1..n_locations]; -% TODO нумерация с нуля array [0..n_operations] of 0..n_locations : operations_destination; % Локация в которой окажется объект после завершения операции. @@ -219,11 +218,9 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац % Операции погрузки, которые используют этот объект в качестве главного или в качестве бункеровщика. array [0..n_moving_obj] of set of 0..n_operations : related_cargo_op; - % TODO узнать про where % Определение is_involved_in_cargo_op. constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals) ( is_involved_in_cargo_op[obj, t] = ( - % (exists (op in 1..n_operations where (not is_moving_operation[op]) /\ (main_obj_of_operation[op] = obj)) ( (exists (op in related_cargo_op[obj]) (op_status[op, t])) \/ ((participation_as_resource[obj, t] != 0) /\ (not is_moving_operation[participation_as_resource[obj, t]])) @@ -301,37 +298,37 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац % Грузообработка. int : n_cargo_types; - int : n_obj_with_storage; - array [0..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of var int : storage_used_volume; % Первые n_moving_obj соответствуют наполненности соответствующих движущихся объектов. + int : n_all_storage_sections; + array [0..n_all_storage_sections, 0..(n_intervals + 1)] of var int : storage_used_volume; - constraint forall (t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) (storage_used_volume[0, t, cargo] = 0); % Фиктивный объект. + constraint forall (t in 0..(n_intervals + 1)) (storage_used_volume[0, t] = 0); % Фиктивный объект. % Ограничения на вместимость. - array [0..n_obj_with_storage] of int : max_storage_vol; + array [0..n_all_storage_sections] of int : max_storage_vol; % Максимальный объём. - constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1)) ( - sum (cargo in 1..n_cargo_types) (storage_used_volume[storage, t, cargo]) <= max_storage_vol[storage] + constraint forall (storage in 1..n_all_storage_sections, t in 0..(n_intervals + 1)) ( + (storage_used_volume[storage, t]) <= max_storage_vol[storage] ); % Неотрицательность объёма. - constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) ( - 0 <= storage_used_volume[storage, t, cargo] + constraint forall (storage in 1..n_all_storage_sections, t in 0..(n_intervals + 1)) ( + 0 <= storage_used_volume[storage, t] ); % Ограничения на граничные значения. - array [0..n_obj_with_storage, 0..n_cargo_types] of int : initial_storage_vol; - array [0..n_obj_with_storage, 0..n_cargo_types] of int : final_storage_vol; + array [0..n_all_storage_sections] of int : initial_storage_vol; + array [0..n_all_storage_sections] of int : final_storage_vol; - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) ( % Initial values. - storage_used_volume[storage, 0, cargo] = initial_storage_vol[storage, cargo] + constraint forall (storage in 1..n_all_storage_sections) ( % Initial values. + storage_used_volume[storage, 0] = initial_storage_vol[storage] ); - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types % Final values. - where final_storage_vol[storage, cargo] >= 0) ( - storage_used_volume[storage, n_intervals + 1, cargo] = final_storage_vol[storage, cargo] + constraint forall (storage in 1..n_all_storage_sections % Final values. + where final_storage_vol[storage] >= 0) ( + storage_used_volume[storage, n_intervals + 1] = final_storage_vol[storage] ); % Изменение грузов в хранилищах. - array [0..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of int : cargo_flows; + array [0..n_all_storage_sections, 0..(n_intervals + 1)] of int : cargo_flows; int : n_loading_op; @@ -339,15 +336,15 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац array [0..n_operations] of int : loading_op_abs_delta; array [0..n_operations] of {1, -1} : loading_op_direction; - array [0..n_operations] of 1..n_obj_with_storage : operations_main_stor; - array [0..n_operations] of 1..n_obj_with_storage : operations_secondary_stor; + array [0..n_operations] of 1..n_all_storage_sections : operations_main_stor; + array [0..n_operations] of 1..n_all_storage_sections : operations_secondary_stor; array [0..n_operations] of 1..n_cargo_types : operations_cargo_t; array [1..n_loading_op] of int : loading_op_delta; array [1..n_loading_op] of {1, -1} : loading_op_local_direction; array [1..n_loading_op] of 1..n_operations : loading_op_n; % Номера среди общего списка операций. - array [1..n_obj_with_storage, 1..n_cargo_types] of set of 1..n_loading_op : involved_operations; + array [1..n_all_storage_sections] of set of 1..n_loading_op : involved_operations; % Интенсивность операций погрузки. array [0..n_operations, 0..(n_intervals + 1)] of var int : cargo_op_intensity; @@ -368,11 +365,11 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац op_status[op, t] -> (cargo_op_intensity[op, t] > 0) ); - constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types, t in 1..(n_intervals + 1)) ( - storage_used_volume[storage, t, cargo] = ( - storage_used_volume[storage, t - 1, cargo] + - cargo_flows[storage, t, cargo] + - sum (inv_op in involved_operations[storage, cargo]) ( + constraint forall (storage in 1..n_all_storage_sections, t in 1..(n_intervals + 1)) ( + storage_used_volume[storage, t] = ( + storage_used_volume[storage, t - 1] + + cargo_flows[storage, t] + + sum (inv_op in involved_operations[storage]) ( cargo_op_intensity[loading_op_n[inv_op], t] * loading_op_local_direction[inv_op] ) @@ -433,15 +430,14 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац constraint forall (op in 1..n_operations, t in 1..n_intervals) ( is_cargo_op_not_exceeds_storage_limits[op, t] = ((not is_moving_operation[op]) -> ( - let {1..n_obj_with_storage : m_stor = operations_main_stor[op]; - 1..n_obj_with_storage : s_stor = operations_secondary_stor[op]; - 1..n_cargo_types : cargo = operations_cargo_t[op]; - int : delta = loading_op_direction[op]; + let {1..n_all_storage_sections : m_stor = operations_main_stor[op]; + 1..n_all_storage_sections : s_stor = operations_secondary_stor[op]; + int : delta = loading_op_direction[op]; } in - (storage_used_volume[m_stor, t, cargo] + delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[m_stor, t, c])) + delta <= max_storage_vol[m_stor]) /\ - (storage_used_volume[s_stor, t, cargo] - delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[s_stor, t, c])) - delta <= max_storage_vol[s_stor]) + (storage_used_volume[m_stor, t] + delta >= 0) /\ + (storage_used_volume[m_stor, t] + delta <= max_storage_vol[m_stor]) /\ + (storage_used_volume[s_stor, t] - delta >= 0) /\ + (storage_used_volume[s_stor, t] - delta <= max_storage_vol[s_stor]) )) ); diff --git a/src/inport/Bunker.java b/src/inport/Bunker.java index d139204808a964337780f692b514aa883950c6f2..bd575d6db255069f87ec43666758e23c7400a1c3 100644 --- a/src/inport/Bunker.java +++ b/src/inport/Bunker.java @@ -4,21 +4,26 @@ */ package inport; +import javafx.util.Pair; + +import java.util.ArrayList; +import java.util.Map; + /** * * @author topazh_ag */ public class Bunker extends TransportShip { - public Bunker(int id, String name, double cargoMax) { - super(id, name, cargoMax); + public Bunker(int id, String name, ArrayList> storageSections) { + super(id, name, storageSections); } public Bunker() { super( ); } - public Bunker(String s) { - super(s); + public Bunker(String s, Map mCargo) { + super(s, mCargo); } } diff --git a/src/inport/ConversionUtil.java b/src/inport/ConversionUtil.java index 02a62591157f601f749290ae40c3a0c600968160..666b5029089752985d736a3e1955dbb6dbd7d83c 100644 --- a/src/inport/ConversionUtil.java +++ b/src/inport/ConversionUtil.java @@ -389,7 +389,34 @@ public class ConversionUtil { private final int nObjWithStorage; - private final Map storNById; + class StorageSectionId implements Comparable { + boolean isRealStorage; // Not transport ship. + Integer localN; + Integer typeN; + + StorageSectionId(boolean isRealStorage, Integer localN, Integer typeN) { + this.isRealStorage = isRealStorage; + this.localN = localN; + this.typeN = typeN; + } + + @Override + public int compareTo(@NotNull StorageSectionId id) { + if (isRealStorage != id.isRealStorage) { + return (isRealStorage ? 1 : -1); + } + if (! localN.equals(id.localN)) { + return localN.compareTo(id.localN); + } + if (! typeN.equals(id.typeN)) { + return typeN.compareTo(id.typeN); + } + return 0; + } + } + + private final Map sectionNById; + private final Map storageNById; private final Map cargoNById; private final Map typeToN; @@ -412,7 +439,7 @@ public class ConversionUtil { n_intervals = (int)task.getPlanningInterval(); berths = new ArrayList<>(task.getBerths()); - locationNumberById = new TreeMap<>(new PairComparator()); + locationNumberById = new TreeMap<>(new PairComparator<>()); for (Berth berth : berths) { locationNumberById.put(new Pair<>(berth.getId(), false), locationNumberById.size()); locationNumberById.put(new Pair<>(berth.getId(), true), locationNumberById.size()); @@ -433,16 +460,36 @@ public class ConversionUtil { storages = new ArrayList<>(task.getStorages()); cargoes = new ArrayList<>(task.getCargoes()); - storNById = new TreeMap<>(); - for (int i = 0; i < storages.size(); i++) { - storNById.put(storages.get(i).getId(), i); - } - cargoNById = new TreeMap<>(); for (int i = 0; i < task.getCargoes().size(); i++) { cargoNById.put(cargoes.get(i).getId(), i); } + int nextStorageNo = 0; + + + storageNById = new TreeMap<>(); + sectionNById = new TreeMap<>(); + + for (int i = 0; i < storages.size(); i++) { + storageNById.put(storages.get(i).getId(), i); + } + + for (MovingObject obj : movingObjects) { + if (obj instanceof TransportShip) { + for (Pair p : ((TransportShip) obj).getStorageSections()) { + sectionNById.put(new StorageSectionId(false, mObjToN(obj), cargoNById.get(p.getKey().getId())), nextStorageNo++); + } + } + } + + for (int i = 0; i < storages.size(); i++) { + storageNById.put(storages.get(i).getId(), i); + for (Pair p : storages.get(i).getStorageSections()) { + sectionNById.put(new StorageSectionId(true, i, cargoNById.get(p.getKey().getId())), nextStorageNo++); + } + } + nObjWithStorage = movingObjects.size() + storages.size(); { @@ -689,112 +736,89 @@ public class ConversionUtil { /* Ограничения на вместимость. */ private void maxStorageVolume() throws IOException { - ArrayList maxStorageVol = new ArrayList<>(); + ArrayList maxStorageVol = integerArray(sectionNById.size(), 0); for (MovingObject obj : movingObjects) { if (obj instanceof TransportShip) { - maxStorageVol.add((int)Math.ceil(((TransportShip) obj).getCargoMax())); - } else { - maxStorageVol.add(0); + for (Pair p : ((TransportShip) obj).getStorageSections()) { + maxStorageVol.set(sectionNById.get(new StorageSectionId(false, + mObjToN(obj), + cargoNById.get(p.getKey().getId()))), + (int)Math.ceil(p.getValue())); + } } } for (Storage storage : storages) { - maxStorageVol.add((int)Math.ceil(storage.getVolume())); + for (Pair p : storage.getStorageSections()) { + maxStorageVol.set(sectionNById.get(new StorageSectionId(true, + storageNById.get(storage.getId()), + cargoNById.get(p.getKey().getId()))), + (int)Math.ceil(p.getValue())); + } } writeArray(writer, "max_storage_vol", maxStorageVol, Optional.of(0)); writer.write("\n"); + } /* Граничные состояния хранилищ. */ private void boundaryStorageStates() throws IOException { // TODO выделить отдельно общий код. - ArrayList> initialStorageVol = new ArrayList<>(); - ArrayList> finalStorageVol = new ArrayList<>(); + ArrayList initialStorageVol = integerArray(sectionNById.size(), 0); + ArrayList finalStorageVol = integerArray(sectionNById.size(), -1); - for (int i = 0; i <= nObjWithStorage; i++) { - initialStorageVol.add(integerArray(cargoes.size() + 1, 0)); - finalStorageVol .add(integerArray(cargoes.size() + 1, -1)); - } - for (StorageState st : task.getStorageInitialState()) { + BiConsumer, StorageState> f = (ArrayList a, StorageState st) -> { int cargoN = cargoNById.get(st.getCargo().getId()); int val = (int)st.getCargoState(); + boolean isRealStorage; + int localN; + if (st.getStorage() instanceof Storage) { Storage storage = (Storage) st.getStorage(); - int stN = storNById.get(storage.getId()); - initialStorageVol.get(movingObjects.size() + stN + 1).set(cargoN + 1, val); - } else if (st.getStorage() instanceof TransportShip) { + isRealStorage = true; + localN = storageNById.get(storage.getId()); + } else { + assert st.getStorage() instanceof TransportShip; + isRealStorage = false; TransportShip ship = (TransportShip) st.getStorage(); - initialStorageVol.get(mObjToN(ship) + 1).set(cargoN + 1, val); + localN = mObjToN(ship); } + + int sectionN = sectionNById.get(new StorageSectionId(isRealStorage, localN, cargoN)); + a.set(sectionN, val); + }; + + for (StorageState st : task.getStorageInitialState()) { + f.accept(initialStorageVol, st); } for (StorageState st : task.getStorageEndState()) { - int cargoN = cargoNById.get(st.getCargo().getId()); - int val = (int)st.getCargoState(); - - if (st.getStorage() instanceof Storage) { - Storage storage = (Storage) st.getStorage(); - int stN = storNById.get(storage.getId()); - finalStorageVol.get(movingObjects.size() + stN + 1).set(cargoN + 1, val); - } else if (st.getStorage() instanceof TransportShip) { - TransportShip ship = (TransportShip) st.getStorage(); - finalStorageVol.get(mObjToN(ship) + 1).set(cargoN + 1, val); - } + f.accept(finalStorageVol, st); } - write2DArrayOfInt(writer, "initial_storage_vol", initialStorageVol, true); - write2DArrayOfInt(writer, "final_storage_vol", finalStorageVol, true); + writeArray(writer, "initial_storage_vol", initialStorageVol, Optional.of(0)); + writeArray(writer, "final_storage_vol", finalStorageVol, Optional.of(-1)); } /* Потоки грузов. */ private void cargoFlows() throws IOException { - ArrayList>> cargoFlows = new ArrayList<>(); - for (int i = 0; i < nObjWithStorage; i++) { - cargoFlows.add(new ArrayList<>()); - for (int j = 0; j < n_intervals + 2; j++) { - cargoFlows.get(i).add(new ArrayList<>()); - for (int k = 0; k < cargoes.size(); k++) { - cargoFlows.get(i).get(j).add(0); - } - } + ArrayList> cargoFlows = new ArrayList<>(); + for (int i = 0; i <= sectionNById.size(); i++) { + cargoFlows.add(integerArray(n_intervals + 2, 0)); } for (CargoFlow flow : task.getCargoFlows()) { - int storageN = storNById.get(flow.getStorage().getId()); - int cargoN = cargoNById.get(flow.getCargo().getId()); + int storageN = sectionNById.get(new StorageSectionId(true, + storageNById.get(flow.getStorage().getId()), + 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 - 0.1)); - } - } - writer.write("cargo_flows = array3d(0..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types, ["); - boolean isFirst = true; - - for (int j = 0; j < n_intervals + 2; j++) { - for (int k = 0; k < cargoes.size(); k++) { - if (isFirst) { - isFirst = false; - } else { - writer.write(", "); - } - writer.write("0"); + cargoFlows.get(storageN + 1).set(i, (int)flow.getCurrentValue(i - 0.1)); } } - for (int i = 0; i < nObjWithStorage; i++) { - for (int j = 0; j < n_intervals + 2; j++) { - for (int k = 0; k < cargoes.size(); k++) { - if (isFirst) { - isFirst = false; - } else { - writer.write(", "); - } - writer.write(cargoFlows.get(i).get(j).get(k).toString()); - } - } - } - writer.write("]);\n\n"); + write2DArrayOfInt(writer,"cargo_flows", cargoFlows, true); } /* Грузовые операции со всеми хранилищами. */ private void cargoOperations() throws IOException { - ArrayList>> involvedOperations = new ArrayList<>(); + ArrayList> involvedOperations = new ArrayList<>(); ArrayList loadingOpDelta = new ArrayList<>(); ArrayList loading_op_local_direction = new ArrayList<>(); ArrayList loadingOpN = new ArrayList<>(); @@ -810,35 +834,35 @@ public class ConversionUtil { ArrayList bunker_of_cargo_op = new ArrayList<>(); - for (int i = 0; i < nObjWithStorage; i++) { + for (int i = 0; i < sectionNById.size(); i++) { involvedOperations.add(new ArrayList<>()); - for (int j = 0; j < cargoes.size(); j++) { - involvedOperations.get(i).add(new ArrayList<>()); - } } for (int i = 0; i < operationTemplates.size(); i++) { if (operationTemplates.get(i) instanceof LoadingTemplate) { LoadingTemplate op = (LoadingTemplate) operationTemplates.get(i); + int shipN = mObjToN(op.getLoader()); + int cargoN = cargoNById.get(op.getCargo().getId()); + int storageN; if (op.getBunker().isPresent()) { - storageN = mObjToN(op.getBunker().get()); + storageN = sectionNById.get(new StorageSectionId(false, mObjToN(op.getBunker().get()), cargoN)); } else { - storageN = storNById.get(op.getStorage().getId()) + movingObjects.size(); + storageN = sectionNById.get(new StorageSectionId(true, storageNById.get(op.getStorage().getId()), cargoN)); } - int shipN = mObjToN(op.getLoader()); - int cargoN = cargoNById.get(op.getCargo().getId()); + + int shipStorageN = sectionNById.get(new StorageSectionId(false, shipN, cargoN)); loadingOpDelta.add(-(int)op.getIntensity()); loading_op_local_direction.add(-(int)op.getIntensity() > 0 ? 1 : -1); loadingOpN.add(i); - involvedOperations.get(storageN).get(cargoN).add(loadingOpDelta.size()); + involvedOperations.get(storageN).add(loadingOpDelta.size()); loadingOpDelta.add((int)op.getIntensity()); loading_op_local_direction.add( (int)op.getIntensity() > 0 ? 1 : -1); loadingOpN.add(i); - involvedOperations.get(shipN).get(cargoN).add(loadingOpDelta.size()); + involvedOperations.get(shipStorageN).add(loadingOpDelta.size()); loading_op_delta_of_main_obj.add((int)op.getIntensity()); loading_op_abs_delta.add(Math.abs((int)op.getIntensity())); @@ -860,11 +884,9 @@ public class ConversionUtil { } } writer.write("n_loading_op = " + loadingOpDelta.size() + ";\n"); - if (task.isTypified()) { - write2DArrayOfSet(writer, "involved_operations", involvedOperations); - } else { - write2DArrayOfSetAs3DArray(writer, "involved_operations", involvedOperations); - } + + writeArray(writer, "involved_operations", involvedOperations, ConversionUtil::arrayToStringAsSet); + writeArray(writer, "loading_op_delta", loadingOpDelta); writeArray(writer, "loading_op_local_direction", loading_op_local_direction); writeArray(writer, "loading_op_n", loadingOpN, (Integer i) -> i + 1); @@ -1243,11 +1265,6 @@ public class ConversionUtil { LoadingTemplate op1 = (LoadingTemplate) operationTemplates.get(i); LoadingTemplate op2 = (LoadingTemplate) operationTemplates.get(j); - if ((! op1.getWithMooring()) && (! op2.getWithMooring()) && - (op1.getStartLocation() == op2.getStartLocation()) && - (op1.getLoader() != op2.getLoader())) { - conflictingOperationsG.get(i).add(j + 1); - } if ((! op1.getWithMooring()) && (! op2.getWithMooring()) && (op1.getStartLocation() == op2.getStartLocation()) && (op1.getBunker().isPresent()) && (op2.getBunker().isPresent())) { @@ -1504,7 +1521,7 @@ public class ConversionUtil { cargoOpUsingObj(); addOpWithNominallyMooring(); - writer.write("n_obj_with_storage = " + nObjWithStorage + ";\n"); + writer.write("n_all_storage_sections = " + sectionNById.size() + ";\n"); writer.write("n_cargo_types = " + cargoes.size() + ";\n"); maxStorageVolume(); @@ -1659,7 +1676,7 @@ public class ConversionUtil { for (String val : opStatus.get(opNo)) { if (val.equals("true") && (templates.get(opNo - 1) instanceof LoadingTemplate)) { LoadingTemplate op = (LoadingTemplate)templates.get(opNo - 1); - cargoOpIntensity.get(opNo).add(Integer.toString((int)Math.ceil(op.getIntensity()))); + cargoOpIntensity.get(opNo).add(Integer.toString((int)Math.ceil(Math.abs(op.getIntensity())))); } else { cargoOpIntensity.get(opNo).add("0"); } diff --git a/src/inport/Main.java b/src/inport/Main.java index 609eaf0fd0d2c38cb187f59dc6b6ffad98a2863c..6843a80e4ddd1d3d97a5e269dca27b6bd42b52fc 100644 --- a/src/inport/Main.java +++ b/src/inport/Main.java @@ -5,16 +5,33 @@ import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; import java.util.function.BiFunction; -import java.util.function.Function; import static inport.Testing.*; -import static inport.Testing.solveTaskWithPartialCargoOp; import inport.ConversionUtil.*; public class Main { - static final int DEFAULT_TIME_LIMIT_S = 1; + private static final int DEFAULT_TIME_LIMIT_S = 3600; + + private enum ConversionType { + Undefined (""), + WithoutSplitting("Without splitting"), + WithSplitting ("With splitting"); + + private final String text; + ConversionType(String text) { + this.text = text; + } + public static ConversionType fromString(String text) { + for (ConversionType t : ConversionType.values()) { + if (t.text.equalsIgnoreCase(text)) { + return t; + } + } + return Undefined; + } + } public static void main(String[] args) { if (args.length == 0) { @@ -40,7 +57,37 @@ public class Main { if (!task.isTypified()) { error = solveTask_1(task, DEFAULT_TIME_LIMIT_S); } else { - error = solveTask_2(task, DEFAULT_TIME_LIMIT_S); + ConversionType t = (args.length == 2) ? ConversionType.WithoutSplitting + : ConversionType.fromString(args[2]); + + String constraintName; + + switch (t) { + case WithSplitting: + constraintName = "conversion_2_with_partial_cargo_operations.mzn"; + break; + case WithoutSplitting: + constraintName = "conversion_2.mzn"; + break; + default: + System.out.println("Undefined conversion type - \"" + args[2] + "\"."); + + ArrayList values = new ArrayList<>(); + for (ConversionType conversionType : ConversionType.values()) { + if (! conversionType.equals(ConversionType.Undefined)) { + values.add("\"" + conversionType.text + "\""); + } + } + System.out.print("Conversion type can be one of " + String.join(", ", values) + "."); + return; + } + + error = solveTask( + task, + constraintName, + ConversionUtil::portToMiniZinc_2, + ConversionUtil::resolveMiniZincResults, + DEFAULT_TIME_LIMIT_S); } long finish = System.currentTimeMillis(); @@ -102,9 +149,16 @@ public class Main { debug(Testing::solveTaskWithPartialCargoOp, DEFAULT_TIME_LIMIT_S); break; } + case "debug read-write" : { + debugReadWrite(); + break; + } case "testing" : test_2(DEFAULT_TIME_LIMIT_S); break; + case "test_experiment": + testGroup("experiments", Testing::solveTask_2, DEFAULT_TIME_LIMIT_S); + break; case "testing_with_partial_op": testWithPartialOp(DEFAULT_TIME_LIMIT_S); break; @@ -161,6 +215,19 @@ public class Main { debugInfo(task, solverResults, output); } + private static void debugReadWrite() { + String fileName = "experiment/in.ipp"; + + TaskCase task = new TaskCase(); + try { + task.deserialize(fileName); + } catch (IOException e) { + System.out.println(e.getMessage()); + return; + } + task.serialize(fileName); + } + private static void debugInfo(TaskCase task, String solverResults, String output) { try (FileInputStream fstream = new FileInputStream(solverResults)) { BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); diff --git a/src/inport/Storage.java b/src/inport/Storage.java index 20b3e280f7d29dd239e998e118e05414ed9d29b4..a05bd4b5d2b64664a6816723b5308ff7f286849d 100644 --- a/src/inport/Storage.java +++ b/src/inport/Storage.java @@ -4,6 +4,9 @@ */ package inport; +import javafx.util.Pair; + +import java.util.ArrayList; import java.util.Map; /** @@ -13,44 +16,13 @@ import java.util.Map; public class Storage { private int id; private String name; - private double volume; - private Cargo cargo; - - /** - * Get the value of cargo - * - * @return the value of cargo - */ - public Cargo getCargo() { - return cargo; - } - - /** - * Set the value of cargo - * - * @param cargo new value of cargo - */ - public void setCargo(Cargo cargo) { - this.cargo = cargo; - } + private ArrayList> storageSections = new ArrayList<>(); - - /** - * Get the value of volume - * - * @return the value of volume - */ - public double getVolume() { - return volume; + public ArrayList> getStorageSections() { + return storageSections; } - - /** - * Set the value of volume - * - * @param volume new value of volume - */ - public void setVolume(double volume) { - this.volume = volume; + public void setStorageSections(ArrayList> storageSections) { + this.storageSections = storageSections; } /** @@ -89,11 +61,10 @@ public class Storage { this.id = id; } - public Storage(int id, String name, double volume, Cargo cargo) { + public Storage(int id, String name, double volume, ArrayList> storageSections) { this.id = id; this.name = name; - this.volume = volume; - this.cargo = cargo; + this.storageSections = storageSections; } public Storage() { @@ -101,15 +72,38 @@ public class Storage { @Override public String toString() { - return id + "; " + name + "; " + cargo.getId() + "; " + volume; + return id + "; " + name + "; " + storageSectionsToString(storageSections); } public Storage(String s, Map cargoes) { String[] tokens = s.split(";"); id = Integer.parseInt(tokens[0].trim()); name = tokens[1].trim(); - volume = Double.parseDouble(tokens[3].trim()); - int key = Integer.parseInt(tokens[2].trim()); - cargo = cargoes.get(key); + storageSections = storageSectionsFromString(tokens[2], cargoes); + } + + static String storageSectionsToString(ArrayList> storageSections) { + ArrayList sections = new ArrayList<>(); + for (Pair p : storageSections) { + sections.add("(" + p.getKey().getId() + ", " + p.getValue() + ")"); + } + return "[" + String.join(", ",sections) + "]"; + } + static ArrayList> storageSectionsFromString(String str, Map cargoes) { + ArrayList> storageSections = new ArrayList<>(); + String sections = str.substring(str.indexOf('[') + 1, str.indexOf(']')); + for (int pos = 0; pos < sections.length(); ) { + int p1 = sections.indexOf('(', pos); + int p2 = sections.indexOf(')', pos); + if ((p1 >= 0) && (p2 >= 0) && (p1 < p2)) { + int type = Integer.parseInt(sections.substring(p1 + 1, sections.indexOf(',', p1)).trim()); + double cargoMax = Double.parseDouble(sections.substring(sections.indexOf(',', p1) + 1, p2).trim()); + storageSections.add(new Pair<>(cargoes.get(type), cargoMax)); + pos = p2 + 1; + } else { + break; + } + } + return storageSections; } } diff --git a/src/inport/TaskCase.java b/src/inport/TaskCase.java index b0716b0ecd07d21c13d31db3782395f0c6a0a5b1..e9fd21bc4a5e8ded42b67f7db46aae7058568d1a 100644 --- a/src/inport/TaskCase.java +++ b/src/inport/TaskCase.java @@ -523,7 +523,7 @@ public class TaskCase { equipmentTypes.put(Integer.parseInt(tokens[0].trim()), tokens[1].trim()); break; case Bunkers: - Bunker bunker = new Bunker(strLine); + Bunker bunker = new Bunker(strLine, m_cargo); bunkers.add(bunker); m_bunker.put(bunker.getId(), bunker); break; @@ -535,7 +535,7 @@ public class TaskCase { break; case Loading_Equipments: LoadingEquipment l = new LoadingEquipment(strLine); equipments.add(l); m_equipment.put(l.getId(), l); m_vessel.put(l.getId(), l); break; - case Transport_Ships: TransportShip ts = new TransportShip(strLine); ships.add(ts); m_vessel.put(ts.getId(), ts); + case Transport_Ships: TransportShip ts = new TransportShip(strLine, m_cargo); ships.add(ts); m_vessel.put(ts.getId(), ts); break; case Templates: tokens = strLine.split(";"); if (tokens[1].trim().equals("mov")) @@ -1400,7 +1400,7 @@ public class TaskCase { writer.write("* Current Storage Volume Constraints \n"); for (Storage st : storages) { - int V = (int)st.getVolume(); + int V = (int) (double) st.getStorageSections().get(0).getValue(); double V0 = 0; for (StorageState sst : storageInitialState) if (sst.getStorage().equals(st)) @@ -1737,7 +1737,7 @@ public class TaskCase { { int i = templates.indexOf(tp); LoadingTemplate ltp = (LoadingTemplate)tp; - if (ltp.getLoader().equals(s) && ltp.getStorage().getCargo().equals(c)) + if (ltp.getLoader().equals(s) && ltp.getStorage().getStorageSections().get(0).getKey().equals(c)) { vc.add(i); int itsv = (int)ltp.getIntensity(); @@ -1779,7 +1779,7 @@ public class TaskCase { nCons++; } // Ограничение на грузоподъемность судна - int maxLoad = (int)(s.getCargoMax()+1.0); + int maxLoad = (int)(s.getStorageSections().get(0).getValue() + 1.0); if (sumplus > (maxLoad - start)) { writer.write(clause + " <= " + (maxLoad - start + epsilon) + " ;\n"); diff --git a/src/inport/Testing.java b/src/inport/Testing.java index 2c5320015bf45c5d2a1e1d49d7913d07afc4731c..a2a2b4f16be0e872c873e038c415572e5a7668c4 100644 --- a/src/inport/Testing.java +++ b/src/inport/Testing.java @@ -1,5 +1,7 @@ package inport; +import javafx.util.Pair; + import java.io.*; import java.util.ArrayList; import java.util.concurrent.TimeUnit; @@ -260,7 +262,11 @@ public class Testing { } } for (TransportShip ship : taskCase.getShips()) { - ship.setCargoMax(ship.getCargoMax() * mult); + ArrayList> sections = new ArrayList<>(); + for (Pair p : ship.getStorageSections()) { + sections.add(new Pair<>(p.getKey(), p.getValue() * mult)); + } + ship.setStorageSections(sections); } for (StorageState state : taskCase.getStorageInitialState()) { state.setCargoState(state.getCargoState() * mult); @@ -269,7 +275,11 @@ public class Testing { state.setCargoState(state.getCargoState() * mult); } for (Storage storage : taskCase.getStorages()) { - storage.setVolume(storage.getVolume() * mult); + ArrayList> sections = new ArrayList<>(); + for (Pair p : storage.getStorageSections()) { + sections.add(new Pair<>(p.getKey(), p.getValue() * mult)); + } + storage.setStorageSections(sections); } for (Operation operation : taskCase.getSolution()) { final double m = mult; diff --git a/src/inport/TransportShip.java b/src/inport/TransportShip.java index 407b86e0e4bdc4937595f0a7d9800a9f7ccfb46d..514e3adffd1614a477809e361687b11e4cb18001 100644 --- a/src/inport/TransportShip.java +++ b/src/inport/TransportShip.java @@ -4,6 +4,10 @@ */ package inport; +import javafx.util.Pair; + +import java.util.ArrayList; +import java.util.Map; import java.util.OptionalInt; /** @@ -11,20 +15,20 @@ import java.util.OptionalInt; * @author topazh_ag */ public class TransportShip extends MovingObject { - - private double cargoMax; - public double getCargoMax() { - return cargoMax; + private ArrayList> storageSections = new ArrayList<>(); + + public ArrayList> getStorageSections() { + return storageSections; } - public void setCargoMax(double cargoMax) { - this.cargoMax = cargoMax; + public void setStorageSections(ArrayList> storageSections) { + this.storageSections = storageSections; } - public TransportShip(int id, String name, double cargoMax) { + public TransportShip(int id, String name, ArrayList> storageSections) { super(id, name); - this.cargoMax = cargoMax; + this.storageSections = storageSections; } public TransportShip() { @@ -32,17 +36,20 @@ public class TransportShip extends MovingObject { @Override public String toString() { - String res = getId() + "; " + getName() + "; " + cargoMax; + String res = getId() + "; " + getName() + "; " + Storage.storageSectionsToString(storageSections); + if (getType().isPresent()) { res += "; " + getType().getAsInt(); } return res; } - public TransportShip(String s) { + public TransportShip(String s, Map cargoes) { super(s); String[] tokens = s.split(";"); - cargoMax = Double.parseDouble(tokens[2].trim()); + + storageSections = Storage.storageSectionsFromString(tokens[2], cargoes); + if (tokens.length >= 4) { setType(OptionalInt.of(Integer.parseInt(tokens[3].trim()))); } diff --git a/tests/requiring_optimization/Case_SPB.tipp b/tests/requiring_optimization/Case_SPB.tipp index bf5d4e6ae6393a74d8156f8debbebfb54c0e5df1..aa4456d0bf6fe9705b85a88acca356a75948969c 100644 --- a/tests/requiring_optimization/Case_SPB.tipp +++ b/tests/requiring_optimization/Case_SPB.tipp @@ -14,9 +14,9 @@ Berths 1; Бункеровочный терминал Горская Storages -2001; Гоское хранилище СПГ; 10002; 1000000 -2002; Хранилище СПГ Кировского завода; 10002; 1000000 -2003; Нефтехранилище; 10001; 1000000 +2001; Гоское хранилище СПГ; [(10002, 1000000)] +2002; Хранилище СПГ Кировского завода; [(10002, 1000000)] +2003; Нефтехранилище; [(10001, 1000000)] Vessel Types 1002; Буксиры @@ -26,17 +26,17 @@ Bunker Types 1001; Бункеровщики Bunkers -11; Бункеровщик 1; 3000; 1001 -12; Бункеровщик 2; 3000; 1001 -13; Бункеровщик 3; 3000; 1001 -14; Бункеровщик 4; 3000; 1001 +11; Бункеровщик 1; [(10002, 3000)]; 1001 +12; Бункеровщик 2; [(10002, 3000)]; 1001 +13; Бункеровщик 3; [(10002, 3000)]; 1001 +14; Бункеровщик 4; [(10002, 3000)]; 1001 Tows -21; Буксир 1; 0; 1002 -22; Буксир 2; 0; 1002 -23; Буксир 3; 0; 1002 -24; Буксир 4; 0; 1002 -25; Буксир 5; 0; 1002 +21; Буксир 1; []; 1002 +22; Буксир 2; []; 1002 +23; Буксир 3; []; 1002 +24; Буксир 4; []; 1002 +25; Буксир 5; []; 1002 Loading Equipment Types 1004; Насосы @@ -45,14 +45,14 @@ Loading Equipments 41; Насос 1; 1004 Transport Ships -31; Танкер 1; 45000; 1003 -32; Танкер 2; 45000; 1003 -33; Танкер 3; 45000; 1003 -34; Танкер 4; 45000; 1003 -35; Танкер 5; 45000; 1003 -36; Танкер 6; 45000; 1003 -37; Танкер 7; 45000; 1003 -38; Танкер 8; 45000; 1003 +31; Танкер 1; [(10001, 45000), (10002, 4500)]; 1003 +32; Танкер 2; [(10001, 45000), (10002, 4500)]; 1003 +33; Танкер 3; [(10001, 45000), (10002, 4500)]; 1003 +34; Танкер 4; [(10001, 45000), (10002, 4500)]; 1003 +35; Танкер 5; [(10001, 45000), (10002, 4500)]; 1003 +36; Танкер 6; [(10001, 45000), (10002, 4500)]; 1003 +37; Танкер 7; [(10001, 45000), (10002, 4500)]; 1003 +38; Танкер 8; [(10001, 45000), (10002, 4500)]; 1003 Templates diff --git a/tests/requiring_optimization/mp.tipp b/tests/requiring_optimization/mp.tipp index 3096c412d54e88c07431037c2a9924752dbb0a15..a4fcdc4d4a266e1f0f843e2d182980e1d58f5430 100644 --- a/tests/requiring_optimization/mp.tipp +++ b/tests/requiring_optimization/mp.tipp @@ -10,22 +10,22 @@ Berths 367; Терминал1 368; Терминал2 Storages -369; Хранилище1; 363; 400 -370; Хранилище2; 364; 400 -371; Хранилище3; 365; 400 +369; Хранилище1; [(363, 400)] +370; Хранилище2; [(364, 400)] +371; Хранилище3; [(365, 400)] Vessel Types 1001; Тип судна1 1002; Тип буксира1 Tows -374; Буксир1; 10000; 1002 -375; Буксир2; 10000; 1002 -376; Буксир3; 10000; 1002 +374; Буксир1; []; 1002 +375; Буксир2; []; 1002 +376; Буксир3; []; 1002 Transport Ships -377; Судно1; 400; 1001 -378; Судно2; 400; 1001 -379; Судно3; 400; 1001 +377; Судно1; [(363, 400), (364, 400), (365, 400)]; 1001 +378; Судно2; [(363, 400), (364, 400), (365, 400)]; 1001 +379; Судно3; [(363, 400), (364, 400), (365, 400)]; 1001 Loading Equipment Types 1003; Тип насоса1 diff --git a/tests/with_typing/Bunkers.tipp b/tests/with_typing/Bunkers.tipp index 0a80c1bff45d08d9b868c58361084b5a49dc814e..5e6714156a314fa40978417dbeeae635d199a706 100644 --- a/tests/with_typing/Bunkers.tipp +++ b/tests/with_typing/Bunkers.tipp @@ -11,7 +11,7 @@ Berths 3; Pier 2 Storages -4; Storage 1; 10001; 10000.0 +4; Storage 1; [(10001, 10000.0)] Vessel Types 1001; Тип судна 1 @@ -20,8 +20,8 @@ Bunker Types 2001; Тип бункировщика 1 Bunkers -201; Bunker 1; 2000.0; 2001 -202; Bunker 2; 2000.0; 2001 +201; Bunker 1; [(10002, 2000.0)]; 2001 +202; Bunker 2; [(10002, 2000.0)]; 2001 Tows @@ -30,8 +30,8 @@ Loading Equipment Types Loading Equipments Transport Ships -101; Ship 1; 2000.0; 1001 -102; Ship 2; 2000.0; 1001 +101; Ship 1; [(10001, 2000.0), (10002, 200.0)]; 1001 +102; Ship 2; [(10001, 2000.0), (10002, 200.0)]; 1001 Templates 7; mov; []; 1001; 1; 2; []; 1.0 diff --git a/tests/with_typing/Case1.tipp b/tests/with_typing/Case1.tipp index 05c2d4c8b293caa6621f503696ef42f4b68d9124..28454682aa77d56a1815c15263a3e58f6159af5b 100644 --- a/tests/with_typing/Case1.tipp +++ b/tests/with_typing/Case1.tipp @@ -10,7 +10,7 @@ Berths 316; Терминал2 Storages -317; Хранилище1; 313; 270.0 +317; Хранилище1; [(313, 270.0)] Vessel Types 1001; Тип судна1 @@ -19,7 +19,7 @@ Vessel Types Bunkers Tows -320; Буксир1; 1000000; 1002 +320; Буксир1; []; 1002 Loading Equipment Types 1003; Кран @@ -28,7 +28,7 @@ Loading Equipments 323; Плавучий кран; 1003 Transport Ships -321; Судно1; 1000000.0; 1001 +321; Судно1; [(313, 1000000.0)]; 1001 Templates 8; mov; []; 1002; 314; 316; []; 1.0 diff --git a/tests/with_typing/Case2.tipp b/tests/with_typing/Case2.tipp index 6f1cc9b83f244b587e4226ff1bdfe0ec90290e9a..94526323a3139384fc624b790713833ec4a70d84 100644 --- a/tests/with_typing/Case2.tipp +++ b/tests/with_typing/Case2.tipp @@ -12,9 +12,9 @@ Berths 88; Терминал2 Storages -89; Хранилище1; 83; 1000.0 -90; Хранилище2; 84; 1000.0 -91; Хранилище3; 85; 1000.0 +89; Хранилище1; [(83, 100.0)] +90; Хранилище2; [(84, 100.0)] +91; Хранилище3; [(85, 100.0)] Vessel Types 1001; Тип судна1 @@ -23,8 +23,8 @@ Vessel Types Bunkers Tows -94; Буксир1; 1000000; 1002 -95; Буксир2; 1000000; 1002 +94; Буксир1; []; 1002 +95; Буксир2; []; 1002 Loading Equipment Types 1003; Тип крана 1 @@ -37,7 +37,7 @@ Loading Equipments 101; Плавучий кран 3; 1005 Transport Ships -96; Судно1; 1000000.0; 1001 +96; Судно1; [(83, 1000.0), (84, 1000.0), (85, 1000.0)]; 1001 Templates 10; mrn; []; 1001; 88; [1002,1002]; 1.0 @@ -46,10 +46,10 @@ Templates 15; mov; []; 1002; 87; 86; []; 1.0 11; mov; []; 1002; 88; 86; []; 1.0 8; mov; []; 1001; 86; 88; [1002]; 2.0 -2; loa; []; 1001; 83; 89; 88; [1003, 1004]; 20.0; M -4; loa; []; 1001; 84; 90; 88; [1003, 1005]; 10.0; M -5; loa; []; 1001; 84; 90; 88; [1004, 1005]; 10.0; M -7; loa; []; 1001; 85; 91; 88; [1005]; 10.0; M +2; loa; []; 1001; 83; 89; 88; [1003, 1004]; 2.0; M +4; loa; []; 1001; 84; 90; 88; [1003, 1005]; 1.0; M +5; loa; []; 1001; 84; 90; 88; [1004, 1005]; 1.0; M +7; loa; []; 1001; 85; 91; 88; [1005]; 1.0; M Cargo Flows @@ -65,9 +65,9 @@ Initial Storage State 83; 89; 0.0 84; 90; 0.0 85; 91; 0.0 -83; 96; 60.0 -84; 96; 60.0 -85; 96; 60.0 +83; 96; 6.0 +84; 96; 6.0 +85; 96; 6.0 Final Vessel State @@ -78,7 +78,7 @@ Final Storage State Task Properties -25.0; 0 +26.0; 0 Solution diff --git a/tests/with_typing/FixedOperations.tipp b/tests/with_typing/FixedOperations.tipp index 22407f746fbe38fefeab7ef556ed5a28c2202c73..d4e56ac5760f64c6cb98c620be7f032dc2bd1843 100644 --- a/tests/with_typing/FixedOperations.tipp +++ b/tests/with_typing/FixedOperations.tipp @@ -10,7 +10,7 @@ Berths 3; Pier 2 Storages -4; Storage 1; 0; 1000.0 +4; Storage 1; [(0, 1000.0)] Vessel Types 1001; Тип судна1 @@ -24,8 +24,8 @@ Loading Equipment Types Loading Equipments Transport Ships -5; Ship 1; 200.0; 1001 -6; Ship 2; 200.0; 1001 +5; Ship 1; [(0, 200.0)]; 1001 +6; Ship 2; [(0, 200.0)]; 1001 Templates 7; mov; []; 1001; 1; 2; []; 1.0 diff --git a/tests/with_typing/TaskBK.tipp b/tests/with_typing/TaskBK.tipp index 4d8ea88a4a5feed22b5db0a47d003c547e39942f..e71b630feee8fb6e5cf156adfd3801300cb16ab4 100644 --- a/tests/with_typing/TaskBK.tipp +++ b/tests/with_typing/TaskBK.tipp @@ -10,7 +10,7 @@ Berths 3; Pier 2 Storages -4; Storage 1; 0; 270.0 +4; Storage 1; [(0, 270.0)] Vessel Types 1001; Тип судна1 @@ -19,7 +19,7 @@ Vessel Types Bunkers Tows -6; Tow 1; 1000000; 1002 +6; Tow 1; []; 1002 Loading Equipment Types 1003; Кран @@ -28,7 +28,7 @@ Loading Equipments 5; Плавучий кран; 1003 Transport Ships -7; Ship 1; 2000.0; 1001 +7; Ship 1; [(0, 2000.0)]; 1001 Templates 8; mov; []; 1001; 1; 2; [1002]; 2.0 diff --git a/tests/with_typing/TaskT.tipp b/tests/with_typing/TaskT.tipp index 2fa835f0eaa8bbaa59bbd3f9ed6d7be081c3e90b..52fdbb404cf7cf4984e68823e5caaad3758c7520 100644 --- a/tests/with_typing/TaskT.tipp +++ b/tests/with_typing/TaskT.tipp @@ -10,7 +10,7 @@ Berths 3; Pier 2 Storages -4; Storage 1; 0; 1000.0 +4; Storage 1; [(0, 200)] Vessel Types 1001; Тип судна1 @@ -26,8 +26,8 @@ Loading Equipment Types Loading Equipments Transport Ships -5; Ship 1; 200.0; 1001 -6; Ship 2; 200.0; 1001 +5; Ship 1; [(0, 40.0)]; 1001 +6; Ship 2; [(0, 40.0)]; 1001 Templates 7; mov; []; 1001; 1; 2; []; 1.0 @@ -36,8 +36,8 @@ Templates 10; mov; []; 1001; 3; 1; []; 1.0 11; mov; []; 1001; 2; 3; []; 1.0 12; mov; []; 1001; 3; 2; []; 1.0 -19; loa; []; 4; 0; 1001; 2; []; 10.0; U -20; loa; []; 4; 0; 1001; 3; []; 5.0; U +19; loa; []; 4; 0; 1001; 2; []; 2.0; U +20; loa; []; 4; 0; 1001; 3; []; 1.0; U Cargo Flows @@ -48,15 +48,15 @@ Initial Vessel State Initial Storage State 0; 5; 0.0 0; 6; 0.0 -0; 4; 1000.0 +0; 4; 200.0 Final Vessel State 5; 1 6; 1 Final Storage State -0; 5; 100.0 -0; 6; 100.0 +0; 5; 20.0 +0; 6; 20.0 Task Properties diff --git a/tests/with_typing/TwoTransports.tipp b/tests/with_typing/TwoTransports.tipp index d7cdff4ba126f2cf6303a43c9f209c56b99556bd..9a0fff5f9099bd59ea21473cfe5478df9b636bd9 100644 --- a/tests/with_typing/TwoTransports.tipp +++ b/tests/with_typing/TwoTransports.tipp @@ -8,7 +8,7 @@ Berths 86; Рейд Storages -89; Хранилище1; 83; 1000.0 +89; Хранилище1; [(83, 1000.0)] Vessel Types 1001; Тип судна1 @@ -22,8 +22,8 @@ Loading Equipment Types Loading Equipments Transport Ships -101; Судно1; 1000000.0; 1001 -102; Судно2; 1000000.0; 1001 +101; Судно1; [(83, 1000000.0)]; 1001 +102; Судно2; [(83, 1000000.0)]; 1001 Templates 1; mrn; []; 1001; 86; []; 1.0 diff --git a/tests/with_typing/mixed_load_op_on_mooring.tipp b/tests/with_typing/mixed_load_op_on_mooring.tipp index b4fc934338f56d2a9935269a153ae643b54773c5..735ada14486f6bbfbdbcb8d844a35ad664316f38 100644 --- a/tests/with_typing/mixed_load_op_on_mooring.tipp +++ b/tests/with_typing/mixed_load_op_on_mooring.tipp @@ -9,7 +9,7 @@ Berths 2; Pier 1 Storages -4; Storage 1; 0; 10000.0 +4; Storage 1; [(0, 10000.0)] Vessel Types 1001; Тип судна1 @@ -24,8 +24,8 @@ Loading Equipment Types Loading Equipments Transport Ships -5; Ship 1; 2000.0; 1001 -6; Ship 2; 2000.0; 1002 +5; Ship 1; [(0, 2000.0)]; 1001 +6; Ship 2; [(0, 2000.0)]; 1002 Templates 7; mov; []; 1001; 1; 2; []; 2.0 diff --git a/tests/with_typing/multiTow.TIPP b/tests/with_typing/multiTow.TIPP index 71441a0b032ed1202c9700f1276f4f017fcbbf2d..e2b833d737b051e99e77f89fa661a421838122f2 100644 --- a/tests/with_typing/multiTow.TIPP +++ b/tests/with_typing/multiTow.TIPP @@ -9,7 +9,7 @@ Berths 16; Терминал1 Storages -18; Хранилище1; 13; 6.0 +18; Хранилище1; [(13, 6.0)] Vessel Types 11; Тип судна1 @@ -18,18 +18,18 @@ Vessel Types Bunkers Tows -121; Буксир1; 1000000; 12 -122; Буксир2; 1000000; 12 -123; Буксир3; 1000000; 12 -124; Буксир4; 1000000; 12 +121; Буксир1; []; 12 +122; Буксир2; []; 12 +123; Буксир3; []; 12 +124; Буксир4; []; 12 Loading Equipment Types Loading Equipments Transport Ships -111; Судно1; 1000000.0; 11 -112; Судно2; 1000000.0; 11 +111; Судно1; [(13, 1000000.0)]; 11 +112; Судно2; [(13, 1000000.0)]; 11 Templates 61; mov; []; 11; 10; 16; [12,12]; 1.0 diff --git a/tests/with_typing/v2.tipp b/tests/with_typing/v2.tipp index 89d6522780c95bdeea02c592466d45ce73cc1ce5..aff244ea18dfd5f8e115fdb883ffbdedbd6c6c92 100644 --- a/tests/with_typing/v2.tipp +++ b/tests/with_typing/v2.tipp @@ -10,8 +10,8 @@ Berths 19; Терминал2 Storages -20; Хранилище1; 22; 100.0 -21; Хранилище2; 22; 100.0 +20; Хранилище1; [(22, 100.0)] +21; Хранилище2; [(22, 100.0)] Vessel Types 1001; Тип судна1 @@ -22,15 +22,15 @@ Bunker Types Bunkers Tows -27; Буксир1; 1000000; 1002 +27; Буксир1; []; 1002 Loading Equipment Types Loading Equipments Transport Ships -24; Судно1; 100000.0; 1001 -25; Судно2; 100000.0; 1001 +24; Судно1; [(22, 100000.0)]; 1001 +25; Судно2; [(22, 100000.0)]; 1001 Templates 4010; mov; []; 1001; 19; 18; [1002]; 1.0