-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for PSO showing how to set max_iterations
- Loading branch information
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from platypus import OMOPSO, DTLZ2 | ||
|
||
# define the problem | ||
problem = DTLZ2() | ||
|
||
# OMOPSO and SMPSO use a non-uniform mutation operator that scales down the magnitude of the mutations | ||
# as the run progresses. Setting max_iterations controls how quickly the non-uniform mutation scales. | ||
swarm_size = 100 | ||
max_iterations = 500 | ||
|
||
algorithm = OMOPSO(problem, epsilons = [0.01], swarm_size = swarm_size, max_iterations = max_iterations) | ||
algorithm.run(swarm_size * max_iterations) | ||
|
||
# display the results | ||
for solution in algorithm.result: | ||
print(solution.objectives) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters