armi.cases.suiteBuilder module
Contains classes that build case suites from perturbing inputs.
The general use case is to create a SuiteBuilder with a base
Case, use addDegreeOfFreedom() to
adjust inputs according to the supplied arguments, and finally use .buildSuite to
generate inputs. The case suite can then be discovered, submitted, and analyzed using
the standard CaseSuite objects.
This module contains a variety of InputModifier objects as well, which are examples
of how you can modify inputs for parameter sweeping. Power-users will generally make
their own Modifiers that are design-specific.
- class armi.cases.suiteBuilder.SuiteBuilder(baseCase)[source]
Bases:
objectClass for constructing a CaseSuite from combinations of modifications on base inputs.
This class provides the capability to create a
CaseSuitebased on programmatic perturbations/modifications to case settings. It works by being constructed with a base or nominalCaseobject. Children classes then append theself.modifierSetsmember. Each entry inself.modifierSetsis aInputModifierrepresenting a case to add to the suite by specifying modifications to the settings of the base case.SuiteBuilder.buildSuite()is then invoked, returning an instance of theCaseSuitecontaining all the cases with modified settings.- Variables:
baseCase (armi.cases.case.Case) – A Case object to perturb
modifierSets (list(tuple(InputModifier))) – Contains a list of tuples of
InputModifierinstances. A single case is constructed by running a series (the tuple) of InputModifiers on the case.
Notes
This is public such that someone could pop an item out of the list if it is known to not work, or be unnecessary.
- addDegreeOfFreedom(inputModifiers)[source]
Add a degree of freedom to the SweepBuilder.
The exact application of this is dependent on a subclass.
- Parameters:
inputModifiers (list(callable(Settings, Blueprints, SystemLayoutInput))) – A list of callable objects with the signature
(Settings, Blueprints, SystemLayoutInput). When these objects are called they should perturb the settings or blueprints by some amount determined by their construction.
- addModifierSet(inputModifierSet: List)[source]
Add a single input modifier set to the suite.
Used to add modifications that are not necessarily another degree of freedom.
- buildSuite(namingFunc=None)[source]
Builds a
CaseSuitebased on the modifierSets contained in the SuiteBuilder.For each sequence of modifications, this creates a new
Casefrom thebaseCase, and runs the sequence of modifications on the newCase’s inputs. The modifiedCaseis then added to aCaseSuite. The resultingCaseSuiteis returned.- Parameters:
namingFunc (callable(index, case, tuple(InputModifier)), (optional)) –
Function used to name each case. It is supplied with the index (int), the case (Case), and a tuple of InputModifiers used to edit the case. This should be enough information for someone to derive a meaningful name.
The function should return a string specifying the path of the
Settings, this allows the user to specify the directories where each case will be run.If not supplied the path will be
./case-suite/<0000>/<title>-<0000>, where<0000>is the four-digit case index, and<title>is thebaseCase.title.- Raises:
RuntimeError – When order of modifications is deemed to be invalid.
- Returns:
caseSuite – Derived from the
baseCaseand modifications.- Return type:
CaseSuite
- class armi.cases.suiteBuilder.FullFactorialSuiteBuilder(baseCase)[source]
Bases:
SuiteBuilderBuilds a suite that has every combination of each modifier.
- addDegreeOfFreedom(inputModifiers)[source]
Add a degree of freedom to the SuiteBuilder.
Creates the Cartesian product of the
inputModifierssupplied and those already applied.For example:
class SettingModifier(InputModifier): def __init__(self, settingName, value): self.settingName = settingName self.value = value def __call__(self, cs, bp): cs = cs.modified(newSettings={self.settingName: self.value}) return cs, bp builder = FullFactorialSuiteBuilder(someCase) builder.addDegreeOfFreedom(SettingModifier("settingName1", value) for value in (1, 2)) builder.addDegreeOfFreedom(SettingModifier("settingName2", value) for value in (3, 4, 5))
would result in 6 cases:
Index
settingName1settingName20
1
3
1
2
3
2
1
4
3
2
4
4
1
5
5
2
5
See also
- class armi.cases.suiteBuilder.FullFactorialSuiteBuilderNoisy(baseCase, noiseFraction)[source]
Bases:
FullFactorialSuiteBuilderAdds a bit of noise to each independent variable to avoid duplicates.
This can be useful in some statistical postprocessors.
Warning
Use with caution. This is part of ongoing research.
- class armi.cases.suiteBuilder.SeparateEffectsSuiteBuilder(baseCase)[source]
Bases:
SuiteBuilderVaries each degree of freedom in isolation.
- addDegreeOfFreedom(inputModifiers)[source]
Add a degree of freedom to the SuiteBuilder.
Adds a case for each modifier supplied.
For example:
class SettingModifier(InputModifier): def __init__(self, settingName, value): self.settingName = settingName self.value = value def __call__(self, cs, bp): cs = cs.modified(newSettings={self.settignName: self.value}) return cs, bp builder = SeparateEffectsSuiteBuilder(someCase) builder.addDegreeOfFreedom(SettingModifier("settingName1", value) for value in (1, 2)) builder.addDegreeOfFreedom(SettingModifier("settingName2", value) for value in (3, 4, 5))
would result in 5 cases:
Index
settingName1settingName20
1
default
1
2
default
2
default
3
3
default
4
4
default
5
See also