Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MixedVariableProblem with arrays of elements #678

Open
patschmidt2 opened this issue Jan 7, 2025 · 2 comments
Open

MixedVariableProblem with arrays of elements #678

patschmidt2 opened this issue Jan 7, 2025 · 2 comments
Assignees

Comments

@patschmidt2
Copy link

Hello,

I am trying to perform an optimization on a mixed variable problem that I would like to describe with something like this:

class MixedVariableProblem(ElementwiseProblem):
    def __init__(self, **kwargs):
        vars = {
            "array1": IntegerArray(len=3, bounds=([1,2,3],[5,6,7]))a,
           "array2": IntegerArray(len=5, bounds=([9, 10, 13, 16, 19],[20, 30, 40, 45, 60]))
        }
        super().__init__(vars=vars, n_obj=1, **kwargs)

However, it seems that currently only simple problems of e.g. only integers are supported. I tried to implement a simple IntegerArray class, but PyMoo internally seems to always expect to be the shape of the individuals to be of (n_offsprings, n_matings, n_var) for the crossover. Is there a way here how I could adapt n_var per variable? Currently, this seems to be a property of the problem and not the individuals.
I would like to have different variables here since the arrays represent different information. I could also try to just create one long array and optimize with, for example, NSGA2, but I want to test custom crossover and mutation operations here.

@blankjul blankjul self-assigned this Jan 12, 2025
@blankjul
Copy link
Collaborator

There are two ways of dealing with this.

  1. The one you are trying to implement to have your own data type. I would need to think a little more if this is possible without modiyfing some classes.
  2. Probably the easier solution. Using the classical GA customazation approach and implementing all the operators. (see here: https://pymoo.org/customization/custom.html)

@patschmidt2
Copy link
Author

Thanks for the hints! Regarding the second option: You mean I then declare n_var = len(array0) + len(array1) + ... and then do the interpretation of this single, large vector in the operators?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants