Hi Fatih,
In MATLAB, the Genetic Algorithm (GA) function ga allows you to optimize a given objective function by varying a set of decision variables. If you have additional parameters that you need to pass to your objective function (like 'setups', 'processing_times', 'due_times', and 'weights' in your case), you can do so using anonymous functions or nested functions that capture these parameters from the enclosing workspace.
Here's an example of how you can set up your optimization using an anonymous function to pass the additional parameters to your objective function:
numVariables = length(processing_times);
objFun = @(sequence) calculate_weighted_makespan(sequence, setups, processing_times, due_times, weights);
options = optimoptions('ga', 'PopulationSize', 100, 'MaxGenerations', 100, ...
[best_sequence, best_weighted_makespan] = ga(objFun, numVariables, [], [], [], [], [], [], [], options);
function weighted_makespan = calculate_weighted_makespan(sequence, setups, processing_times, due_times, weights)
In this example, 'objFun' is an anonymous function that wraps your 'calculate_weighted_makespan' function and includes the additional parameters that won't change during the optimization. When you call the 'ga' function, you pass 'objFun' as the objective function to be optimized. The GA will then optimize the sequence variable, while the other parameters ('setups', 'processing_times', 'due_times', and 'weights') are passed through unchanged.
Remember to replace [...] with your actual data for setups, processing times, due times, and weights. The 'numVariables' should be set to the number of decision variables in your problem (for example, the length of the sequence array that needs to be optimized). The 'options' line is optional and can be customized based on your specific requirements for the GA algorithm.
I hope the above solution resolves the issue.
Thank you.