Code Monkey home page Code Monkey logo

Comments (5)

thieupu avatar thieupu commented on June 2, 2024

Hi @cumttc,

You can pass a matrix of positions with shape (pop_size, n_dims) in a solver like this:
https://mealpy.readthedocs.io/en/latest/pages/general/advance_guide.html#starting-solutions

from mealpy.

cumttc avatar cumttc commented on June 2, 2024

Hi@thieupu

Hi @cumttc,

You can pass a matrix of positions with shape (pop_size, n_dims) in a solver like this: https://mealpy.readthedocs.io/en/latest/pages/general/advance_guide.html#starting-solutions

If my initial solution is [1, 2, 3, 4], then the 'starting_solutions' I need to pass in is np.ones((pop_size, 4)) @ np.diag(1, 2, 3, 4).
Is it correct?

from mealpy.

thieupu avatar thieupu commented on June 2, 2024

@cumttc ,

Mealpy is population-based algorithms, so the starting_solutions of any algorithm is a matrix of population and problem size.
If your initial solution is [1, 2, 3, 4]. And you have pop_size = 10 (agents).
Then you should set starting_solutions like this:

import numpy as np

pop_size = 10
problem_size = n_dims = 4

initial = np.array([1, 2, 3, 4])
starting = [ initial + np.random.uniform(-0.1, 0.1, n_dims) for _ in range(0, pop_size-1) ]
starting_solutions = np.array( [initial, ] + starting )

You should never set starting_solutions with the same position for all agents. That is not a good practice.

from mealpy.

cumttc avatar cumttc commented on June 2, 2024

Thanks for the answer, but one more question:
What should I do if I have additional parameters that are not involved in the optimization, but need to be passed into the objective function?

from mealpy.

thieu1995 avatar thieu1995 commented on June 2, 2024

@cumttc ,

Then you should define a custom problem like this:
https://mealpy.readthedocs.io/en/latest/pages/general/advance_guide.html#custom-problem

You can pass anything you want into that class.

from mealpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.