Skip to content

Commit

Permalink
added logic to run InverseFORM.run() if seed is provided in init
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-krill committed Sep 1, 2023
1 parent 6236297 commit 9704aa0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/UQpy/reliability/taylor_series/InverseFORM.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def __init__(
Only one of :code:`p_fail` or :code:`beta` may be provided.
:param seed_x: Point in the parameter space :math:`\mathbf{X}` to start from.
Only one of :code:`seed_x` or :code:`seed_u` may be provided.
If neither is provided, the zero vector in :math:`\mathbf{U}` space is the seed.
If either :code:`seed_u` or :code:`seed_x` is provided, then the :py:meth:`run` method will be executed automatically.
:param seed_u: Point in the uncorrelated standard normal space :math:`\mathbf{U}` to start from.
Only one of :code:`seed_x` or :code:`seed_u` may be provided.
If neither is provided, the zero vector in :math:`\mathbf{U}` space is the seed.
If either :code:`seed_u` or :code:`seed_x` is provided, then the :py:meth:`run` method will be executed automatically.
:param df_step: Finite difference step in standard normal space. Default: :math:`0.01`
:param corr_x: Correlation matrix :math:`\mathbf{C_X}` of the random vector :math:`\mathbf{X}`
:param corr_z: Correlation matrix :math:`\mathbf{C_Z}` of the random vector :math:`\mathbf{Z}`
Expand Down Expand Up @@ -130,6 +130,13 @@ def __init__(
self.state_function: list = []
"""State function :math:`G(u)` evaluated at each step in the optimization"""

if (seed_x is not None) and (seed_u is not None):
raise ValueError('UQpy: Only one input (seed_x or seed_u) may be provided')
if self.seed_u is not None:
self.run(seed_u=self.seed_u)
elif self.seed_x is not None:
self.run(seed_x=self.seed_x)

def run(self, seed_x: Union[list, np.ndarray] = None, seed_u: Union[list, np.ndarray] = None):
"""Runs the inverse FORM algorithm.
Expand Down

0 comments on commit 9704aa0

Please sign in to comment.