Comments (2)
Hello amir1m! I hope everything is going well with you!
Sorry for not having a script that depicts on how to use the actual optimization problem to make the convergence plot. We ran into some issues where people used to say that there was not file to be loaded and opted to remove such an example.
Nevertheless, here is a draft that might help you:
import numpy as np
from opytimark.markers.n_dimensional import Sphere
from opytimizer import Opytimizer
from opytimizer.core import Function
from opytimizer.optimizers.swarm import PSO
from opytimizer.spaces import SearchSpace
import opytimizer.visualization.convergence as c
# Random seed for experimental consistency
np.random.seed(0)
# Number of agents and decision variables
n_agents = 20
n_variables = 2
# Lower and upper bounds (has to be the same size as `n_variables`)
lower_bound = [-10, -10]
upper_bound = [10, 10]
# Creates the space, optimizer and function
space = SearchSpace(n_agents, n_variables, lower_bound, upper_bound)
optimizer = PSO()
function = Function(Sphere())
# Bundles every piece into Opytimizer class
opt = Opytimizer(space, optimizer, function, save_agents=False)
# Runs the optimization task
opt.start(n_iterations=1000)
# Retrieves the best agent's position and fitness
best_agent_pos, best_agent_fit = opt.history.get_convergence('best_agent')
# Plots the convergence of x0 and x1
c.plot(best_agent_pos[0], best_agent_pos[1])
Note that the idea is to retrieve a list of positions/fitness through the get_convergence()
method of the History
class. With these lists, it is possible to feed them to the convergence.plot()
method.
Additionally, after performing an optimization, you can save the whole task using opt.save()
and load it into another script with opt = Opytimizer.load()
. The History
object will be available as an property of Opytimizer, e.g., opt.history
.
Please let me know if it works!
Best regards,
Gustavo.
from opytimizer.
Awesome! Works as expected.
Thanks @gugarosa ! Appreciate the quick turnaround!
Take care.
Amir
from opytimizer.
Related Issues (20)
- [REG] Strange testing pattern HOT 1
- [BUG] AttributeError: 'History' object has no attribute 'show' HOT 5
- [NEW] Constrained optimization HOT 4
- GA roulette selection method [REG] HOT 1
- [NEW] Different number of step for each variable HOT 3
- [NEW] Dump optimization progress HOT 4
- [REG] How to get best agent values? HOT 2
- positions HOT 2
- [REG] How to supress DEBUG log message in opytimizer.core.space HOT 4
- [BUG] Gaussian multiplicative noise may lead to unexpected behaviours on GA HOT 2
- [REG]Is there a way to provide initial values before starting optimization? HOT 2
- [BUG] HOT 6
- [NEW] Define objective function for regression problem HOT 2
- [REG] HOT 3
- [REG] What is the difference between grid space, and discrete space example? HOT 3
- [REG] How to get a detailed print out during optimization? HOT 2
- [NEW] HOT 1
- [NEW] Using population data for population-based algorithms? HOT 3
- Aranha, C., Camacho Villalón, C.L., Campelo, F., Dorigo, M., Ruiz, R., Sevaux, M., Sörensen, K. and Stützle, T., 2022. Metaphor-based metaheuristics, a call for action: The elephant in the room. Swarm Intelligence, 16(1), pp.1-6.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opytimizer.