I need to optimize the work of 3 AMR robots carring a workbench in a factory.
every robot can move to 3 places where a worker can use the workbench
I have diferents jobs, every job need a specific sequence. The sequence of the job
is expressed as the sequence of places.
Suppose that I have 3 different jobs.
Job1 = [place1, place2, place3]
Job2 = [place1, place3, place2]
Job3 = [place1, place3]
a single robot to coplete de job must follow the sequence of the job
a place can be used for 1 robot.
the tilme to work in the single jobs related to the places are:
Job1 = [3, 3 ,2]
Job2 = [3, 2, 2]
Job3 = [1, 1]
I need to do job1 3 times , job 2 5 times and job 3 2 times.
I want to optimize the job so I need to optimize the movement of the robots
I want a scheduling that minimize the time elapsed and maximize the
as output i need a Minizinc program that can handle this example and a more generic problems with the same constraint but different input values
Assistant
Certainly! Let's start by rewriting your problem in terms of optimization to use the MiniZinc constraint solver. Given the problem, we need to minimize the total time for completing the jobs with robots, respecting the specific sequence of tasks required by each job.
MiniZinc Model:
Here's a MiniZinc model that captures your problem with the constraints described. This model can be adapted to different numbers of jobs, robots, places, and sequences.
minizinc
include "globals.mzn";
% Input parameters
int: num_robots = 3;
int: num_places = 3;
int: num_jobs = 3;
int: total_runs[num_jobs] = [3, 5, 2]; % Number of times each job needs to be done
% Job sequences as the order of places
set of int: Places = 1..num_places;
set of int: Jobs = 1..num_jobs;
array[Jobs, int] of int: job_sequences = [
[1, 2, 3, 0],
[1, 3, 2, 0],
[1, 3, 0, 0]
];
% Time required by each job at each place
array[Jobs, int] of int: times = [
[3, 3, 2, 0],
[3, 2, 2, 0],
[1, 1, 0, 0]
];
% Number of sequences of a job
array[Jobs] of int: sequence_length = [
3, 3, 2
];
% Decision Variables
array[1..sum(total_runs), 1..num_places] of var 0..sum(times): start_times;
array[1..sum(total_runs)] of var 0..total_runs[1]: job_types;
% Helper function to get job time at a place
function var int: job_time(int: job_id, int: place_index) =
times[job_id, place_index];
% Constraints
constraint
forall(job in 1..sum(total_runs)) (
let {
var int: job_type = job_types[job]
} in
forall(seq in 1..sequence_length[job_type]) (
let {
var int: place = job_sequences[job_type, seq],
var int: time = job_time(job_type, seq)
} in
place > 0 -> start_times[job, place] >= if seq > 1 then start_times[job, job_sequences[job_type, seq-1]] + job_time(job_type, seq-1) else 0 endif
)
);
% Ensuring only one job at a place at a time
constraint
forall(job1 in 1..sum(total_runs), job2 in 1..sum(total_runs), place in 1..num_places where job1 != job2)(
start_times[job1, place] != start_times[job2, place]
);
% Objective: Minimize the maximum end time of all jobs
var int: max_time = max([start_times[j, last_job_sequence[j]] + job_time(job_types[j], last_job_sequence[j]) | j in 1..sum(total_runs), last_job_sequence[j] in 1..num_places where job_sequences[job_types[j], last_job_sequence[j]] > 0]);
solve minimize max_time;
Explanation:
Input Parameters: Defines the number of robots, places, jobs, and the sequence along with the time for each job.
Job Sequences: Defines the specific sequences in which places must be visited to complete each job.
Times: Specifies the time it takes at each place for each job.
Decision Variables:
start_times: When each job starts at a specific place.
job_types: The type of job for each run.
Constraints:
Enforces the sequence of tasks within each job.
Ensures that no two jobs occupy the same place simultaneously.
Objective: Minimizes the maximum end time of all tasks, effectively aiming to complete all jobs as quickly as possible.
Consult the MiniZinc documentation for specific functions and constraints if minor adjustments are required for more complex scenarios or specific edge cases.