Commit 49424e24 authored by Vladislav Kiselev's avatar Vladislav Kiselev

Улучшено представление ограничений.

parent 3c72d73d
......@@ -20,7 +20,7 @@ constraint forall (obj in 1..n_moving_obj, j in 1..(n_intervals + 1))
((m_obj_loc[obj, j] != 0) -> (
(m_obj_loc[obj, j] == m_obj_loc[obj, j - 1] /\ (forall (k in departure_op[obj, m_obj_loc[obj, j]]) (op_status[k, j - 1] == 0)))
\/
(not (forall (k in arrival_op[obj, m_obj_loc[obj, j]]) (op_fin[k, j - 1] == 0)))
(exists (k in arrival_op[obj, m_obj_loc[obj, j]]) (op_fin[k, j - 1] != 0))
));
% Начальное состояние.
......@@ -98,23 +98,26 @@ array [1..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of var int
% Ограничения на вместимость.
array [1..n_obj_with_storage] 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])
/\
(forall (cargo in 1..n_cargo_types) (0 <= storage_used_volume[storage, t, cargo]))
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_obj_with_storage, t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) ( % Неотрицательность объёма.
0 <= storage_used_volume[storage, t, cargo]
);
% Ограничения на граничные значения.
array [1..n_obj_with_storage, 1..n_cargo_types] of int : initial_storage_vol;
array [1..n_obj_with_storage, 1..n_cargo_types] of int : final_storage_vol;
constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) (
(storage_used_volume[storage, 0, cargo] = initial_storage_vol[storage, cargo])
/\
(if final_storage_vol[storage, cargo] >= 0 then
(storage_used_volume[storage, (n_intervals + 1), cargo] == final_storage_vol[storage, cargo])
else
true
endif)
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_obj_with_storage, cargo in 1..n_cargo_types) ( % Final values.
if final_storage_vol[storage, cargo] >= 0 then
storage_used_volume[storage, n_intervals + 1, cargo] == final_storage_vol[storage, cargo]
else true
endif
);
% Изменение грузов в хранилищах.
......@@ -212,11 +215,11 @@ array [1..n_moving_obj, 0..(n_intervals + 1)] of var bool : is_interval_useful;
);
constraint forall (obj in 1..n_moving_obj, t in 0..n_intervals) ( % Само ограничение.
if ((m_obj_loc[obj, t] != 0) /\ (next_m_obj_loc[obj, t + 1] != 0) /\ (m_obj_loc[obj, t + 1] == 0)) then
if (next_m_obj_loc[obj, t + 1] == prev_m_obj_loc[obj, t]) then
is_interval_useful[obj, t] == true
endif
endif
(( m_obj_loc[obj, t] != 0) /\
(prev_m_obj_loc[obj, t] != 0) /\
( m_obj_loc[obj, t + 1] == 0) /\
(next_m_obj_loc[obj, t + 1] == prev_m_obj_loc[obj, t])
) -> is_interval_useful[obj, t]
);
solve minimize sum(is_not_terminated);
......
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