I am trying to implement an optimisation using gp_minimize from skopt. However my objective functions needs some objects to work on, similar to this:
def objective(optimisation_parameters, trees):
trees.manipulate(optimisation_parameters)
trees.shake()
return trees.count_fallen_fruits()
def optimise():
trees = [tree.Tree() for _ in range(0,5)]
res = gp_minimize(objectiv,space,...,args = trees)
Is there any (proper) way to do this? I have several ideas:
- Read and store the trees in a pickle file each optimisation
- Define the trees so that they are in scope for the objective function
Thanks
Your idea 2 is the common option. It is utilized in this example.
A scratch based on your code snippets might look like this: