Closed harsha3080 closed 1 year ago
Unfortunately, I also reached the same problem. It turns out that the constraint optimization methods provided by Platypus, compute the value for every solution for a constrained problem, yielding a vector with the individual magnitude of violation for each solution and a total penalty. In the documentation they clearly state:
The final population could contain infeasible and dominated solutions if the number of function evaluations was insufficient (e.g. algorithm.Run(100)). In this case, we would need to filter out the infeasible solutions.
Personally, I'm not a fan of having this particular implementation! The user should be provided with the option to select the intended use of a constrained optimization method: either hard constraint or soft constraint.
I was also facing similar issue.I am trying to solve a multi-objective constrained problem using NSGA-II algorithm available in platypus. Problem has two objectives one is to minimize while the other objective is to maximize the value, with one of the constraints is sum of variable so selected should be equal to one.
The problem is supposed to provide optimization results if the variables so selected satisfies mentioned constraints.It is observed that while evaluating the algorithm, constraints are being violated to met the objective mentioned.
Is there any way to assign weights to constraints to ensure that particular constraint is satisfied always for optimized results? Is there any way to ensure that constraints are never being violated for specified objective?
This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.
The following is my code:
(In File 2): import math import random import operator import functools from platypus.core import Problem, Solution, EPSILON from platypus.types import Real, Binary from abc import ABCMeta from retaining_wall_2ga_20p import opt from check import intersection_constr
Depth_of_Excavation = 9 x1 = 5 x2= 20 x3 = -15 x4 = -40 x5 = 7 x6 = 10 x7 = 1 x8 = 10
count = 0
class wall(Problem):
I run the file 1 below....everything is working fine but the population mostly violating constrains.
(In File 1):
from newtask import NSGAII from newtaskk import wall
problem = wall() algorithm = NSGAII(problem) algorithm.run(1350) for solution in algorithm.result: print(solution.variables) print(solution.objectives)