Skip to content

Commit 6af7b0b

Browse files
enable runnign your own workflow in the CMOOP
1 parent da33750 commit 6af7b0b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/studies/multi_objective_optimization.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mutable struct StudyMultiObjectiveOptimizer{T<:Real} <: AbstractStudy
3939
dataframe::Union{DataFrame,Missing}
4040
datafame_filtered::Union{DataFrame,Missing}
4141
generation::Int
42+
workflow::Union{Function,Missing}
4243
end
4344

4445
function StudyMultiObjectiveOptimizer(
@@ -50,8 +51,7 @@ function StudyMultiObjectiveOptimizer(
5051
kw...
5152
)
5253
sty = OverrideParameters(sty; kw...)
53-
study = StudyMultiObjectiveOptimizer(sty, ini, act, constraint_functions, objective_functions, nothing, missing, missing, 0)
54-
54+
study = StudyMultiObjectiveOptimizer(sty, ini, act, constraint_functions, objective_functions, nothing, missing, missing, 0, missing)
5555
check_and_create_file_save_mode(sty)
5656

5757
parallel_environment(sty.server, sty.n_workers)
@@ -111,8 +111,12 @@ function _run(study::StudyMultiObjectiveOptimizer)
111111

112112
@assert !isempty(sty.save_folder) "Specify where you would like to store your optimization results in sty.save_folder"
113113

114+
if ismissing(study.workflow)
115+
study.workflow = optimization_workflow_default
116+
end
117+
114118
study.state = workflow_multiobjective_optimization(
115-
study.ini, study.act, ActorWholeFacility, study.objective_functions, study.constraint_functions;
119+
study.ini, study.act, study.workflow, study.objective_functions, study.constraint_functions;
116120
optimization_parameters..., generation_offset=study.generation, sty.database_policy,
117121
sty.number_of_generations, sty.population_size)
118122

@@ -233,4 +237,15 @@ function filter_outputs(outputs::DataFrame, constraint_symbols::Vector{Symbol})
233237
constraint_values = [outputs[i, key] for key in constraint_symbols, i in 1:n]
234238
all_constraint_idxs = findall(i -> all(x -> x == 0.0, constraint_values[:, i]), 1:n)
235239
return outputs[all_constraint_idxs, :]
240+
end
241+
242+
"""
243+
optimization_workflow_default(ini::ParametersAllInits, act::ParametersAllActors)
244+
Default optimization workflow when study.workflow isn't set, initializes and runs the whole facility actor
245+
"""
246+
function optimization_workflow_default(ini::ParametersAllInits, act::ParametersAllActors)
247+
dd = FUSE.IMAS.dd()
248+
FUSE.init(dd, ini, act)
249+
FUSE.ActorFluxMatcher(dd, act)
250+
return dd
236251
end

0 commit comments

Comments
 (0)