Skip to content

Commit

Permalink
Merge pull request #29 from nasa/box-behnken
Browse files Browse the repository at this point in the history
Added BoxBehnken
  • Loading branch information
pjuangph authored Jan 30, 2023
2 parents 98392e8 + bcee7ae commit daee6a4
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 239 deletions.
40 changes: 39 additions & 1 deletion glennopt/DOE/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,47 @@ def from_dict(self, settings: dict):
self.alpha = settings['alpha']
self.face =settings['face']

class BoxBehnken(DOE):
def __init__(self,center_points:int=1):
"""Box Behnken design of experiments. Their primary advantage is in addressing the issue of where the experimental boundaries should be, and in particular to avoid treatment combinations that are extreme. Extreme = corner and star points.
Args:
center (int, optional): Number of levels within the min and max values. Defaults to 4.
"""
super(BoxBehnken, self).__init__()
self.center_points=center_points

def create_design(self):
param_dict = dict()
for p in self.eval_parameters:
r = np.linspace(p.min_value ,p.max_value)
param_dict[p.name] = r.tolist()

df = build.box_behnken(param_dict,center=self.center_points)
return df

def to_dict(self):
"""Export the settings used to create the optimizer to dict. Also exports the optimization results if performed
Returns:
Dict: dictionary object
"""
settings = DOE.to_dict(self) # call super class
settings['doe_name'] = 'fullfactorial'
settings['levels'] = self.levels
return settings

def from_dict(self, settings: dict):
"""creates the object from a dictionary
Args:
settings (dict): dictionary object created by calling to_dict()
"""
super().from_dict(settings)
self.levels = settings['levels']

class FullFactorial(DOE):
def __init__(self,levels=4):
def __init__(self,levels:int=4):
"""Factorial based design of experiments. number of evaluations scale with 2^(level-1)
Args:
Expand Down
2 changes: 1 addition & 1 deletion glennopt/DOE/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import absolute_import

from .Experiment import Default, CCD, FullFactorial,LatinHyperCube
from .Experiment import Default, CCD, FullFactorial,LatinHyperCube, BoxBehnken
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "GlennOPT"
version = "1.4.6"
version = "1.4.7"
description = "Multi and single objective optimization tool for cfd/computer simulations."
authors = ["Paht Juangphanich <[email protected]>"]

Expand Down
Loading

0 comments on commit daee6a4

Please sign in to comment.