Multi-Objective Optimization in Matlab

Hello everyone and welcome!

In this post, I’m going to show you a simple but very effective method to solve multi-objective optimization problems in Matlab.  It’s very easy to use this method and minimum programming skill is required.

This method is based on multi-objective optimization genetic algorithm solver in Matlab. If you want to download this Matlab code, go down to the end of the post.

In this video, we use unconstrained optimization problem to test its performance. For those who are interested in constrained multi-objective optimization, please check other videos related to multi-objective optimization on this channel.

Here are the details of the test function:

Let’s see how this multi-objective optimization genetic algorithm solver works.

For more videos like this, check my YouTube channel here.

Matlab code:

multi_objective_function.m

function Output = multi_objective_function(Input)

x1 = Input(1); % variable 1
x2 = Input(2); % variable 2
x3 = Input(3); % variable 3

F1 = 1 - exp(-((x1 - 1/sqrt(3))^2 + (x2 - 1/sqrt(3))^2 + (x3 - 1/sqrt(3))^2)); % objective 1
F2 = 1 - exp(-((x1 + 1/sqrt(3))^2 + (x2 + 1/sqrt(3))^2 + (x3 + 1/sqrt(3))^2)); % objective 2

Output = [F1 F2];

multi_objective_genetic_algorithm_solver.m

function [x,fval,exitflag,output,population,score] = multi_objective_genetic_algorithm_solver(nvars,lb,ub,PopulationSize_Data,MaxGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data)
options = optimoptions('gamultiobj');
options = optimoptions(options,'PopulationSize', PopulationSize_Data);
options = optimoptions(options,'MaxGenerations', MaxGenerations_Data);
options = optimoptions(options,'FunctionTolerance', FunctionTolerance_Data);
options = optimoptions(options,'ConstraintTolerance', ConstraintTolerance_Data);
options = optimoptions(options,'CrossoverFcn', {  @crossoverintermediate [] });
options = optimoptions(options,'Display', 'off');
options = optimoptions(options,'PlotFcn', { @gaplotpareto });
[x,fval,exitflag,output,population,score] = ...
gamultiobj(@multi_objective_function,nvars,[],[],[],[],lb,ub,[],options);

Main_program.m

clc
clear all
close all

nvars = 3;
lb = [-4 -4 -4];
ub = [4 4 4];
PopulationSize_Data = 100; 
MaxGenerations_Data = 50; 
FunctionTolerance_Data = 0; 
ConstraintTolerance_Data = 0; 

[x,fval,exitflag,output,population,score] = multi_objective_genetic_algorithm_solver(nvars,lb,ub,PopulationSize_Data,MaxGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data);

optimal_solution = x

P/s: If you find the post useful, share it to remember and to help other people as well.

35 Replies to “Multi-Objective Optimization in Matlab”

  1. Hello! sir, I want to do optimization on the centrifugal compressor. so can you please make a video of at least the process of how to do it, that can be really very helpful.

    Thank you.

      1. Hi, I’m Santhosh from studying masters in Taiwan. As part of my research, I want to do genetic algorithm optimization for centrifugal compressors. So could you please help me with that by making a video? that would be greatly helped me. Thanks in advance.

        1. Hello, Santhosh! Thanks for your suggestion. May I see your problem formation, i.e. objective function(s) and constraints?

          1. sir, can you send me your mail id so that I will send the objective functions and constraints to you.
            Eagerly waiting for your reply.
            Thank you.

  2. Hello Sir
    Can you do a video about MultiObjective Particle Swarm Optimization in the field of electrical enfineering.

  3. Dear Dr.Panda,

    thank you for your educations.
    I need to create a fitness function from the MLP neural network to optimize using NSGA2.
    Can you help me write the fitness function from ANN?
    Do I have to load artificial neural network data into the NSGA2?
    Where?

    thank you so much

    Best regards

    Saeedeh Zarbakhsh
    saeedeh.zarbakhsh@yahoo.com

  4. Hello sir, thank you very much for all your content. Maybe u could make a video on how to solve optimization problems using artificial immune systems? In fact, I’m trying to use The Danger Immune Algorithm to solve an optimization problem on how to avoid ship collisions. Your videos inspired me to start working on this project. Thank you.

    1. Sorry, I don’t have the background to fully understand your problem. Only thing I can do now is to advise you to try to understand the working principle of my Matlab/Python codes and then modify/customize/update them to solve the optimization problems in your fields.

  5. Hello, I hope you’re doing well. I apologize for bothering you; I wanted to inquire if it’s possible to obtain your code. I need the NSGA2 code for my thesis.

  6. Hello, good evening. I need a base article, for example, “optimal power exchange in interconnected microgrids with a centralized or decentralized control approach” that has ideas for the future, and I have studied about 400 journal articles so far, but the article I want I couldn’t find it, please help me. In addition, I have a criticism from you that about 6 days ago, I also asked for an example of coding a multi-objective function for interconnected microgrids (cluster) in MATLAB environment, but you did not respond to the email sent through the Gmail address. I hope you will respond to my requests as soon as possible. Please take care with thanks and respect Fazli

  7. Hello, dear management, thank you for your reply. I have been working for a long time on the coding of the article entitled “Centralized controller for the optimal operation of a cooperative cluster of connected microgrids powered multi-greenhouses” in MATLAB, but unfortunately I could not reach the simulation results (diagram) of the article, please help me and the steps of MATLAB coding, please send me the article, of course I sent the article through your email, but I don’t know if it reached you. Thanks and regards

  8. Hello, please code the article titled Centralized controller for the optimal operation of a cooperative cluster of
    connected microgrids powered multi-greenhouses
    Please help me faster. Of course, I sent you the article file with Jamil, but it was returned, that’s why I wrote the title of the article, so please get the article file from the site, thank you.

  9. Hello sir, thank you for your communication. Please send me an email so that I can send you the article file
    with respect

  10. Hello, please send me the MATLAB coding method of the article titled “Centralized controller for optimal performance of multi-greenhouse connected microgrids cooperative cluster”.It will be a good guide for writing my dissertation. I hope this pleasant event will happen soon.
    With respect

Leave a Reply

Your email address will not be published. Required fields are marked *