[BUG] Constraints are seen as non-linear in the multi-objective case
- Dominant language
- C++
- Stars
- 536
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
I want to implement a multi-objective problem with two objectives and one constraint. However, when I am executing it, I get an error `what: Non linear constraints detected in instance.`, with which my solver cannot deal (NSGA-||); however my constraint is non-linear.
To reproduce, I created a small example:
import pygmo as pg
```
class SimpleProblem:
# objective functions and constraints
def fitness(self, x):
fitness_vector = []
# first objective
fitness_vector.append(x[0])
constants = [1,0.5,0.5]
# second objective
fitness_vector.append(-sum([x[i] * constants[i] for i in range(3)]))
# constraint
fitness_vector.append(sum([x[i] for i in range(3)]) -2)
return fitness_vector
# number of objectives
def get_nobj(self):
return 2
# number of inequality constraints
def get_nic(self):
return 1
# real dimension of the problem
def get_ncx(self):
return 1
# integer dimension of the problem
def get_nix(self):
return 3
# bounds of the decision variables
def get_bounds(self):
return ([0] + [0] * 3, [1e6] + [1] * 3)
if __name__ == "__main__":
model = SimpleProblem()
problem = pg.problem(model)
algorithm = pg.algorithm(pg.nsga2(gen=1000))
population = pg.population(problem, size=100)
population = algorithm.evolve(population)
```
I read drom the documentation, that to add objectives and constraints, one shall return a vector first containing the objectives followed by the constraints in the fitness function. However I do not know if this differs with multi-objectives, as I did not find any example for multi-objective optimization with constraints other than the variable bounds in the documentation. Hence I do not know if this is a bug or if I am supposed to give the objectives/constraints differently.
I am using Version 2.19.5.
Any help would be appreciated
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.