-5

I am trying to apply the concept of Genetic Algorithm to solve a non-linear optimization problem in Python and compare the results with other methods. I am trying to solve min (x1.x2^2 + x1+x2) to get the optimal solution using GA. I have solved the problem using scipy and gekko , but i need to use GA for comparison and learning purposes.

Any suggestions? Thank you.

Mohamad Ibrahim
  • 315
  • 2
  • 8

1 Answers1

1

You can use JMetalPy, a Python implementation for the JMetal Meta-heuristic search library.

You need to define and implement how to encode your solutions and implement a fitness function.

Fakher Mokadem
  • 1,059
  • 1
  • 8
  • 22
  • Dear Fakher, thank you for your reply. My aim is to minimize the non-linear function: x1x2^2 + x2 +x1 ; I have solved this used scipy and gekko. However, I want to make sure if I can use GA to solve the same problem. – Mohamad Ibrahim Nov 25 '19 at 20:03
  • 1
    well, for that encode your solution as the pair of reals (x1, x2) and set the fitness function to -x1x2^2 + xx2 + x1. Also, if this was helpful please upvote and accept the answer – Fakher Mokadem Nov 26 '19 at 08:57
  • 1
    correction: the fitness function should be: - x1x2^2 -x2 - x1 – Fakher Mokadem Nov 27 '19 at 08:14
  • 1
    Dear Fakher, I have one more question. How should I add the constraints to the problem? Suppose for instance x1+x2 <2 for instance. – Mohamad Ibrahim Nov 27 '19 at 20:34
  • 1
    ofcourse you should, and you do that when you are defining your solution space (set of feasible solutions). --please accept the answer if this was helpful(it's the tick under the upvote) – Fakher Mokadem Nov 28 '19 at 09:23