Answers.Body: <p>I eventually used the keep-efficient function from <a href="https://stackoverflow.com/a/32793059/453673">this answer</a> to calculate the Pareto front and used the k-means function to calculate the centroid of the front. This gave me the approximate knee-point of the front, which is usually the optimal solution. One of the calculations was to maximise the distance moved in x direction (dx) vs. minimising the energy consumed (e), so since the x axis needed positive maximization and the y axis needed minimization, I inverted the y axis, since <code>min(f(y)) = - max(-f(y))</code>. This helped get the pareto front toward the top right side of the graph and both the x and y axes were maximization objectives. The optimal point calculated was the robot that had the best fitness.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-29T16:29:11.730Z
Answers.LastActivityDate: 2020-07-29T16:29:11.730Z
Answers.UserDisplayName: Nav
Body: <p><strong>What I did:</strong><br>
  Created a population of 2D legged robots in a simulated environment. Found the best motor rotation values to make the robots move rightward, using an objective function with Differential Evolution (could use PSO or GA too), that returned the distance moved rightward. Gradient descent used for improving fitness.  </p>
  
  <p><strong>What I want to do:</strong><br>
  Add more objectives. To find the best motor rotation, with the least motion possible, with the least jittery motion, without toppling the body upside down and making the least collision impact on the floor.  </p>
  
  <p><strong>What I found:</strong>  </p>
  
  <ul>
  <li><p>Spent almost two weeks searching for solutions, reading research
  papers, going through tutorials on Pareto optimality, installing
  libraries and trying the example programs.</p></li>
  <li><p>Using <a href="https://en.wikipedia.org/wiki/Pairing_function" rel="nofollow noreferrer">pairing functions</a> to create a cost function wasn't good
  enough.</p></li>
  <li><p>There are many <a href="https://www.google.com/search?client=firefox-b-d&amp;q=multi%20objective%20evolutionary%20algorithms" rel="nofollow noreferrer">multi-objective PSO, DE, GA etc.</a>, but they seem
  to be built for solving some other kind of problem.</p></li>
  </ul>
  
  <p><strong>Where I need help:</strong>  </p>
  
  <ul>
  <li><p>Existing multi objective algorithms seem to use some pre-existing
  minimization and maximization functions (Fonseca, Kursawe, OneMax,
  DTLZ1, ZDT1, etc.) and it's confusing to understand how I can use my
  own maximization and minimization functions with the libraries.
  (minimize(motorRotation), maximize(distance),
  minimize(collisionImpact), constant(bodyAngle)).</p></li>
  <li><p>How do I know which is the best Pareto front to choose in a
  multi-dimensional space? There seem to be ways of choosing the
  top-right Pareto front or the top-left or the bottom-right or
  bottom-left. In multi-dimensional space, it'd be even more varied.</p></li>
  <li><p>Libraries like Platypus, PyGMO, Pymoo etc. just define the problem using
  <code>problem = DTLZ2()</code>, instantiate an algorithm <code>algorithm =
  NSGAII(problem)</code> and run it <code>algorithm.run(10000)</code>, where I assume
  10000 is the number of generations. But since I'm using a legged
  robot, I can't simply use <code>run(10000)</code>. I need to assign motor values
  to the robots, wait for the simulator to make the robots in the
  population move and then calculate the objective function cost. How
  can I achieve this?  </p></li>
  <li><p>Once the pareto optimal values are found, how is it used to create a
  cost value that helps me determine the fittest robot in the
  population?</p></li>
  </ul>
  
Tags: <genetic-algorithms><evolutionary-algorithms><gradient-descent>
Title: How to calculate multiobjective optimization cost for ordinary problems?
UserDisplayName: Nav
ThreadText: # How to calculate multiobjective optimization cost for ordinary problems?
  
  (Asked by: username_0 on 2019-10-02)
  
  **What I did:**  
  Created a population of 2D legged robots in a simulated environment. Found the best motor rotation values to make the robots move rightward, using an objective function with Differential Evolution (could use PSO or GA too), that returned the distance moved rightward. Gradient descent used for improving fitness.
  
  **What I want to do:**  
  Add more objectives. To find the best motor rotation, with the least motion possible, with the least jittery motion, without toppling the body upside down and making the least collision impact on the floor.
  
  **What I found:**
  
  * Spent almost two weeks searching for solutions, reading research
    papers, going through tutorials on Pareto optimality, installing
    libraries and trying the example programs.
  * Using [pairing functions](https://en.wikipedia.org/wiki/Pairing_function) to create a cost function wasn't good
    enough.
  * There are many [multi-objective PSO, DE, GA etc.](https://www.google.com/search?client=firefox-b-d&q=multi%20objective%20evolutionary%20algorithms), but they seem
    to be built for solving some other kind of problem.
  
  **Where I need help:**
  
  * Existing multi objective algorithms seem to use some pre-existing
    minimization and maximization functions (Fonseca, Kursawe, OneMax,
    DTLZ1, ZDT1, etc.) and it's confusing to understand how I can use my
    own maximization and minimization functions with the libraries.
    (minimize(motorRotation), maximize(distance),
    minimize(collisionImpact), constant(bodyAngle)).
  * How do I know which is the best Pareto front to choose in a
    multi-dimensional space? There seem to be ways of choosing the
    top-right Pareto front or the top-left or the bottom-right or
    bottom-left. In multi-dimensional space, it'd be even more varied.
  * Libraries like Platypus, PyGMO, Pymoo etc. just define the problem using
    `problem = DTLZ2()`, instantiate an algorithm `algorithm =
    NSGAII(problem)` and run it `algorithm.run(10000)`, where I assume
    10000 is the number of generations. But since I'm using a legged
    robot, I can't simply use `run(10000)`. I need to assign motor values
    to the robots, wait for the simulator to make the robots in the
    population move and then calculate the objective function cost. How
    can I achieve this?
  * Once the pareto optimal values are found, how is it used to create a
    cost value that helps me determine the fittest robot in the
    population?
  
  **Tags:** genetic-algorithms, evolutionary-algorithms, gradient-descent
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-07-29. Score: 0 | Accepted answer
  
  I eventually used the keep-efficient function from [this answer](https://stackoverflow.com/a/32793059/453673) to calculate the Pareto front and used the k-means function to calculate the centroid of the front. This gave me the approximate knee-point of the front, which is usually the optimal solution. One of the calculations was to maximise the distance moved in x direction (dx) vs. minimising the energy consumed (e), so since the x axis needed positive maximization and the y axis needed minimization, I inverted the y axis, since `min(f(y)) = - max(-f(y))`. This helped get the pareto front toward the top right side of the graph and both the x and y axes were maximization objectives. The optimal point calculated was the robot that had the best fitness.
  
  
  ---
  
  