Commit ac2467fe authored by Vladislav Kiselev's avatar Vladislav Kiselev

Различные грузы теперь хранятся отдельно в хранилищах со своим объёмом, убраны...

Различные грузы теперь хранятся отдельно в хранилищах со своим объёмом, убраны избыточные хранилища с нулевым объёмом.
parent fcf4d282
......@@ -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];
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])
)) /\ % Если это операция грузообработки, то она не выведет
% объём берегового хранилища и хранилища судна за
% границы дозволенного.
......
......@@ -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];
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])
))
);
......
......@@ -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<Pair<Cargo, Double>> storageSections) {
super(id, name, storageSections);
}
public Bunker() {
super( );
}
public Bunker(String s) {
super(s);
public Bunker(String s, Map<Integer, Cargo> mCargo) {
super(s, mCargo);
}
}
This diff is collapsed.
......@@ -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<String> 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));
......
......@@ -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;
private ArrayList<Pair<Cargo, Double>> storageSections = new ArrayList<>();
/**
* Get the value of cargo
*
* @return the value of cargo
*/
public Cargo getCargo() {
return cargo;
public ArrayList<Pair<Cargo, Double>> getStorageSections() {
return storageSections;
}
/**
* Set the value of cargo
*
* @param cargo new value of cargo
*/
public void setCargo(Cargo cargo) {
this.cargo = cargo;
}
/**
* Get the value of volume
*
* @return the value of volume
*/
public double getVolume() {
return volume;
}
/**
* Set the value of volume
*
* @param volume new value of volume
*/
public void setVolume(double volume) {
this.volume = volume;
public void setStorageSections(ArrayList<Pair<Cargo, Double>> 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<Pair<Cargo, Double>> 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<Integer, Cargo> 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<Pair<Cargo, Double>> storageSections) {
ArrayList<String> sections = new ArrayList<>();
for (Pair<Cargo, Double> p : storageSections) {
sections.add("(" + p.getKey().getId() + ", " + p.getValue() + ")");
}
return "[" + String.join(", ",sections) + "]";
}
static ArrayList<Pair<Cargo, Double>> storageSectionsFromString(String str, Map<Integer, Cargo> cargoes) {
ArrayList<Pair<Cargo, Double>> 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;
}
}
......@@ -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");
......
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<Pair<Cargo, Double>> sections = new ArrayList<>();
for (Pair<Cargo, Double> 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<Pair<Cargo, Double>> sections = new ArrayList<>();
for (Pair<Cargo, Double> p : storage.getStorageSections()) {
sections.add(new Pair<>(p.getKey(), p.getValue() * mult));
}
storage.setStorageSections(sections);
}
for (Operation operation : taskCase.getSolution()) {
final double m = mult;
......
......@@ -4,6 +4,10 @@
*/
package inport;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.Map;
import java.util.OptionalInt;
/**
......@@ -12,19 +16,19 @@ import java.util.OptionalInt;
*/
public class TransportShip extends MovingObject {
private double cargoMax;
private ArrayList<Pair<Cargo, Double>> storageSections = new ArrayList<>();
public double getCargoMax() {
return cargoMax;
public ArrayList<Pair<Cargo, Double>> getStorageSections() {
return storageSections;
}
public void setCargoMax(double cargoMax) {
this.cargoMax = cargoMax;
public void setStorageSections(ArrayList<Pair<Cargo, Double>> storageSections) {
this.storageSections = storageSections;
}
public TransportShip(int id, String name, double cargoMax) {
public TransportShip(int id, String name, ArrayList<Pair<Cargo, Double>> 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<Integer, Cargo> 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())));
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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