pythonarraysnumpyoptimizationpymoo

Dynamic Lists as Decision Variables in pymoo


I want to define the problem of parallel machine scheduling in pymoo, i.e. I have given:

The results should be a list of lists, each presenting an ordering of jobs on the respective machine.

This is what I have so far:

class ParallelScheduling(ElementwiseProblem):

def __init__(self, n_machines, processing_times, release_dates, due_dates, **kwargs):

    self.n_jobs = processing_times.shape[0]
    self.n_machines = n_machines
    self.processing_times = processing_times
    self.release_dates = release_dates
    self.due_dates = due_dates
    
    super(ParallelScheduling, self).__init__(
        n_var=??,
        n_obj=2,
        xl=??,
        xu=??,
        vtype=int,
        **kwargs
    )

def _evaluate(self, X, out, *args, **kwargs):
    out["F"] = sum(np.sum(get_tardiness(x)) for x in X)
    out["G"] = -sum(np.sum(get_intime_jobs(x)) for x in X)

Now the decision variables are lists of a variable length, as each machine could in theory have a different number of jobs, but I am not sure how I can implement this.

An alternative solution I came up with was using an array of length n_jobs and assigning the machines to the indices of their jobs (thus having n_jobs decision variables with bounds 0 to n_machines) But this does not include the ordering in which the jobs are executed on the machines, which is relevant here.

The encoding here is generally a little bit problematic, since I used numpy.arrays everywhere, but I just realized now that I can not use them to create arrays which contain arrays of different sizes.

Any help would be appreciated, either on how to do this using the approach I have already or alternativly on how to define a problem with a more freely choosable encoding in pymoo.


Solution

  • Turns out pymoo offers such feature: https://pymoo.org/customization/custom.html