Integer Programming model doesn’t converge in MiniZinc

Here’s the corrected version of your message:

Hello, I am working on an exercise in integer programming using MiniZinc. My code struggles to converge: when the data is small, it runs successfully, but when the data gets larger, it runs for 30–40 minutes, shows several solutions, but still does not converge to an optimal solution.

I would appreciate your help in identifying why my code isn’t optimized.

Here is the problem description, the data, and my code.

We are asked to plan the maintenance of a wind farm. Tasks requiring the stopping of wind turbines must be carried out in order to control the condition of the structures and possibly to fix them. The difficulty of the problem stems from the fact that the number of technicians is limited and that we
 want to minimize the loss of production linked to the shutdown of wind turbines. The weather forecast indicates the expected production of each wind turbine, thus making it possible to plan production stoppages at the least troubling moments.
 We want to plan I tasks over N weeks, with K technician.
 — Each week is divided into 5 working days. Each day has 3 periods, the two morning and afternoon work periods for 4 hours each, and the "rest" period (the latter symbolizes the night between 2 working days, and the weekend for day 5).
 — Each task i ∈ I takes place on a wind turbine ei, lasts di periods of work and requires a technician. A task cannot be interrupted, and two tasks cannot be in progress at the same time on the same wind turbine. A task of length 2 can be started one afternoon, so it will end the next morning; however, the task is still considered in progress during the rest period and therefore the wind turbine cannot produce for 3 periods.
 — Each technician k ∈ K can only work on one task at a time.
 — We try to maximize the total energy production over the N weeks thanks to the forecasts
 of individual production of each wind turbine. A wind turbine can only produce if it is not occupied by a task. The total production is the sum of the productions of each wind turbine at each period.

data.dzn

n_employee = 6;
n_turbin = 8;
n_tasks = 19;

n_week = 1;
n_day = n_week*5;
n_period = n_day*3;


productivity = array2d(1..n_turbin,1..n_period,     [5,7,7, 2,3,2, 3,2,2, 4,8,5, 4,7,6,
                                                      6,5,6, 3,3,2, 2,4,3, 5,7,3, 5,6,5,
                                                      5,5,6, 2,4,3, 3,3,3, 4,8,2, 4,7,6,
                                                      5,6,5, 3,3,2, 2,2,2, 6,6,4, 6,8,7,
                                                      7,7,8, 2,2,2, 3,3,2, 4,8,2, 4,7,6,
                                                      6,5,6, 4,3,4, 4,2,3, 4,6,3, 5,6,8,
                                                      5,5,7, 2,2,4, 4,3,2, 5,7,2, 6,6,5,
                                                      6,7,7, 2,3,3, 3,2,2, 6,8,4, 4,7,6]);
      
on_turbin = array1d(1..n_tasks,[1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,7,7,8,8]);                                                
length = array1d(1..n_tasks,[3,1,4,3,1,4,3,1,2,3,2,3,2,3,2,3,2,3,2]);


n_skills = 3;
%skills[i,j] indique si le technicien i a le skill j
skills = array2d(1..n_employee,1..n_skills,[1,1,1,
                                            1,0,1,
                                            1,1,0,
                                            0,1,1,
                                            0,1,1,
                                            1,0,0]);
                                            
%indique quel skill est requis pour quelle tâche
skill_req = array1d(1..n_tasks,[1,1,1,2,1,2,3,1,2,3,2,3,2,3,1,1,2,3,2]);

The Minizinc code (the most difficult is the time constraint, work and rest). I think the main problem is from here.

int: n_employee;    % Number of technicians
int: n_turbin;      % Number of turbines
int: n_tasks;       % Number of tasks
int: n_week;        % Number of weeks
int: n_day;         % Number of working days per week
int: n_period;      % Total periods (n_day * 3)
% Productivity of each turbine for each period (n_turbin x n_period matrix)
array[1..n_turbin, 1..n_period] of int: productivity;
array[1..n_tasks] of int: on_turbin;

% Duration of each task
array[1..n_tasks] of int: length;
array[1..n_tasks] of int: skill_req; % Required skill for each task
int: n_skills;                       % Number of skills
array[1..n_employee, 1..n_skills] of int: skills; % Technician skills matrix

% Decision variables
array[1..n_tasks] of var 0..n_period: start_time; % Start time for each task
array[1..n_tasks] of var 0..n_period: end_time; % End time for each task
array[1..n_tasks] of var 1..n_employee: assigned_technician; % Technician for each task

% Derived variable: turbine downtime
array[1..n_turbin, 1..n_period] of var 0..1: downtime;

% Constraints
constraint forall(t in 1..n_tasks) (
    on_turbin[t] == on_turbin[t] /
    start_time[t] mod 3 != 0 /
    end_time[t] = start_time[t] + length[t] - 1 
                + sum([1 | p in start_time[t] .. start_time[t] + length[t] - 1 where p mod 3 == 0]) /
    end_time[t] mod 3 != 0 /
    end_time[t] <= n_period
);
% Handle rest period: if a task spans across the rest period, block that period too
constraint forall(t in 1..n_tasks, p in start_time[t]..end_time[t]) (
    downtime[on_turbin[t], p] == 1
);

% No overlap on the same turbine
constraint forall(t1 in 1..n_tasks, t2 in t1+1..n_tasks) (
    on_turbin[t1] == on_turbin[t2] -> 
    (end_time[t1] < start_time[t2] / 
     end_time[t2] < start_time[t1])
);

% Technician cannot work on two tasks at the same time
constraint forall(k in 1..n_employee, t1 in 1..n_tasks, t2 in t1+1..n_tasks) (
    assigned_technician[t1] == k / assigned_technician[t2] == k ->
    (end_time[t1] < start_time[t2] / 
     end_time[t2] < start_time[t1])
);

% Ensure each task is assigned to one technician with the required skill
constraint forall(i in 1..n_tasks)(
    skills[assigned_technician[i], skill_req[i]] == 1);

% Objective: Maximize total production
var int: total_production = sum(t in 1..n_turbin, p in 1..n_period) (
    (1 - downtime[t, p]) * productivity[t, p]
);

solve maximize total_production;

Thank you very much for your assistance!

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật