Skip to content

Commit

Permalink
Add multithreaded evaluation component
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnebro committed Jun 11, 2024
1 parent ac82350 commit 1fab137
Show file tree
Hide file tree
Showing 5 changed files with 719 additions and 710 deletions.

Large diffs are not rendered by default.

1,078 changes: 537 additions & 541 deletions notebooks/NSGA-II notebook.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/MetaJul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export BLXAlphaCrossover, SBXCrossover, SinglePointCrossover, IntegerSBXCrossove
export recombine, numberOfDescendants, numberOfRequiredParents
include("operator/crossover.jl")

export SequentialEvaluation, SequentialEvaluationWithArchive
export SequentialEvaluation, SequentialEvaluationWithArchive, MultithreadedEvaluation
include("component/common/evaluation.jl")

export DefaultSolutionsCreation
Expand Down
14 changes: 14 additions & 0 deletions src/component/common/evaluation.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Random
using Base.Threads

struct SequentialEvaluation <: Evaluation
problem::Problem
Expand All @@ -22,3 +23,16 @@ function evaluate(evaluation::SequentialEvaluationWithArchive, solutions::Vector
end
return solutions
end

struct MultithreadedEvaluation <: Evaluation
problem::Problem
end

function evaluate(evaluation::MultithreadedEvaluation, solutions::Vector{S}) where {S<:Solution}

@threads for solution in solutions
evaluate(solution, evaluation.problem)
end

return solutions
end
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MetaJul

using Test

# Utility functions
Expand Down

0 comments on commit 1fab137

Please sign in to comment.