Skip to content

Commit

Permalink
Add test with only final analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFP committed Aug 4, 2023
1 parent 94b71b9 commit 3d98895
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_chain_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,51 @@ def test_chain_evaluator():
exploration.run()


def test_chain_evaluator_only_final_analysis():
"""Test a ChainEvaluator where only the final TemplateEvaluator has an
analysis function."""
# Define variables and objectives.
var1 = VaryingParameter('x0', -50., 5.)
var2 = VaryingParameter('x1', -5., 15.)
obj = Objective('f', minimize=False)

# Define variables and objectives.
gen = RandomSamplingGenerator(
varying_parameters=[var1, var2],
objectives=[obj]
)

# Create template evaluator.
ev1 = TemplateEvaluator(
sim_template=os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'resources',
'template_simulation_script.py'
)
)
ev2 = TemplateEvaluator(
sim_template=os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'resources',
'template_simulation_script_2.py'
),
analysis_func=analysis_func_2
)
ev = ChainEvaluator([ev1, ev2])

# Create exploration.
exploration = Exploration(
generator=gen,
evaluator=ev,
max_evals=10,
sim_workers=2,
exploration_dir_path='./tests_output/test_chain_evaluator_2'
)

# Run exploration.
exploration.run()


if __name__ == '__main__':
test_chain_evaluator()
test_chain_evaluator_only_final_analysis()

0 comments on commit 3d98895

Please sign in to comment.