Parameters¤
A parameter marks a quantity of the structure — a force density, a load component, a support coordinate — as a variable the optimizer is allowed to change, optionally bounded.
Base classes¤
parameters
¤
Parameter
¤
Parameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
The base class for all optimization parameters.
Parameters:
-
key(int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]]) –The key of the element in the datastructure being parametrized.
-
bound_low(float | None, default:None) –The lower bound for optimization. If None, unbounded below.
-
bound_up(float | None, default:None) –The upper bound for optimization. If None, unbounded above.
Notes
Concrete subclasses set attr_name to the datastructure attribute they
parametrize and implement index and value for their element type.
Missing bounds normalize to negative or positive infinity rather than None.
index
¤
index(structure: EquilibriumStructure) -> int
Resolve the parameter's key to an index in an equilibrium structure.
Parameters:
-
structure(EquilibriumStructure) –The structure whose element ordering defines the index.
Returns:
-
index(int) –The index of the parametrized element.
value
¤
evaluate
¤
Evaluate the parameter directly on a datastructure.
Parameters:
Returns:
-
value(float) –The current value of the parametrized attribute.
Notes
A parameter reads straight off the datastructure, so this is a thin alias
for value; it needs no structure, model, or sparse flag. It rounds
out the evaluate family so goals, constraints, and parameters share one
prototyping entry point.
ParameterGroup
¤
ParameterGroup(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
The base class for a single parameter shared across a group of elements.
Notes
A group parameter drives one value that is applied to, and read as the average over, all its elements. Its key is always a sequence of element keys.
Parameters:
-
key(Sequence[int] | Sequence[tuple[int, int]]) –The keys of the elements sharing the parameter.
-
bound_low(float | None, default:None) –The lower bound for optimization. If None, unbounded below.
-
bound_up(float | None, default:None) –The upper bound for optimization. If None, unbounded above.
index
¤
ParameterManager
¤
ParameterManager(model: EquilibriumModel, parameters: Sequence[Parameter], structure: EquilibriumStructure, network: FDNetwork | FDMesh)
Order, bound, and split optimization parameters for the FDM optimizer.
Parameters:
-
model(EquilibriumModel) –The equilibrium model.
-
parameters(Sequence[Parameter]) –The optimization parameters to manage.
-
structure(EquilibriumStructure) –The structure the parameters are defined on.
-
network(FDNetwork | FDMesh) –The network or mesh the parameters read their initial values from.
Notes
On construction the manager precomputes the type-sorted parameter ordering, the optimizable/frozen split, and the index maps between optimization space and the flat model parameter vector, so later property access is static.
startindex_fd
property
¤
startindex_fd: int
The starting index of the force density of the edges of a network.
startindex_xyzfixed
property
¤
startindex_xyzfixed: int
The starting index of the xyz coordinates of the anchor nodes of a network.
startindex_loads
property
¤
startindex_loads: int
The starting index of the xyz coordinates of the loads at the nodes of a network.
indices_fd
property
¤
indices_fd: Int[ndarray, edges]
The ordered indices of the force density of the edges of a network.
indices_xyzfixed
property
¤
indices_xyzfixed: Int[ndarray, supports]
The ordered indices of the xyz coordinates of the support nodes of a network.
indices_loads
property
¤
indices_loads: Int[ndarray, loads]
The ordered indices of the xyz coordinates of the anchor nodes of a network.
indices_groups
property
¤
indices_groups: Int[ndarray, parameters]
A list with indices distributions optimization parameters to parameter groups.
indices_opt
property
¤
indices_opt: Int[ndarray, parameters]
The type-ordered indices of the optimization parameters.
indices_opt_sort
property
¤
indices_opt_sort: Int[ndarray, parameters]
The indices that sort the index-based ordering of the type-sorted optimization parameters.
indices_opt_unsort
property
¤
indices_opt_unsort: Int[ndarray, parameters]
The indices that unsort the index-based ordering of the type-sorted optimization parameters.
bounds_low
property
¤
bounds_low: Float[ndarray, parameters]
Return an array with the lower bound of the optimization parameters.
bounds_up
property
¤
bounds_up: Float[ndarray, parameters]
Return an array with the upper bound of the optimization parameters.
parameters_value
property
¤
parameters_value: Float[Array, parameters]
Return an array with the intial value of the optimization parameters.
parameters_ordered
property
¤
The optimization parameter objects, sorted by type.
parameters_model
property
¤
parameters_model: Float[Array, parameters]
The model parameters as a single array.
parameters_opt
property
¤
parameters_opt: Float[Array, parameters]
The optimizable model parameters.
parameters_frozen
property
¤
parameters_frozen: Float[Array, parameters]
The non-optimizable model parameters.
init
¤
init() -> None
Initialiaze the properties of this object so that every property becomes static after this call.
TODO: This is fairly anti-pythonic. Please refactor me.
parameters_fdm
¤
parameters_fdm(params_opt: Float[Array, parameters]) -> tuple[Float[Array, edges], Float[Array, 'supports 3'], Float[Array, 'nodes 3']]
Expand optimization parameters into the FDM model parameters.
Parameters:
-
params_opt(Float[Array, parameters]) –The flat optimization parameter vector.
Returns:
-
params_fdm(tuple[Float[Array, edges], Float[Array, 'supports 3'], Float[Array, 'nodes 3']]) –The force densities, fixed node coordinates, and node loads, merged with the frozen parameters and reshaped for the model.
mask_optimizable
¤
mask_optimizable(array: Float[Array, parameters]) -> tuple[Int[ndarray, parameters], Bool[ndarray, parameters]]
Build masks separating the optimizable parameters from the frozen ones.
Parameters:
-
array(Float[Array, parameters]) –The flat parameter array to shape the masks after.
Returns:
mask_fdm
¤
Edge parameters¤
parameters
¤
Node parameters¤
parameters
¤
NodeLoadXParameter
¤
NodeLoadXParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the x component of a node load.
NodeLoadYParameter
¤
NodeLoadYParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the y component of a node load.
NodeLoadZParameter
¤
NodeLoadZParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the z component of a node load.
NodeSupportXParameter
¤
NodeSupportXParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the X coordinate of a support node.
NodeSupportYParameter
¤
NodeSupportYParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the Y coordinate of a support node.
NodeSupportZParameter
¤
NodeSupportZParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the Z coordinate of a support node.
NodeGroupLoadXParameter
¤
NodeGroupLoadXParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the X component of the load applied to a group of nodes.
NodeGroupLoadYParameter
¤
NodeGroupLoadYParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the Y component of the load applied to a group of nodes.
NodeGroupLoadZParameter
¤
NodeGroupLoadZParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the Z component of the load applied to a group of nodes.
NodeGroupSupportXParameter
¤
NodeGroupSupportXParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the X coordinate of a group of support nodes.
Vertex parameters¤
parameters
¤
VertexLoadXParameter
¤
VertexLoadXParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the x component of a vertex load.
VertexLoadYParameter
¤
VertexLoadYParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the y component of a vertex load.
VertexLoadZParameter
¤
VertexLoadZParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the z component of a vertex load.
VertexSupportXParameter
¤
VertexSupportXParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the X coordinate of a support vertex.
VertexSupportYParameter
¤
VertexSupportYParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the Y coordinate of a support vertex.
VertexSupportZParameter
¤
VertexSupportZParameter(key: int | tuple[int, int] | Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize the Z coordinate of a support vertex.
VertexGroupLoadXParameter
¤
VertexGroupLoadXParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the X component of the load applied to a group of vertices.
VertexGroupLoadYParameter
¤
VertexGroupLoadYParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the Y component of the load applied to a group of vertices.
VertexGroupLoadZParameter
¤
VertexGroupLoadZParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the Z component of the load applied to a group of vertices.
VertexGroupSupportXParameter
¤
VertexGroupSupportXParameter(key: Sequence[int] | Sequence[tuple[int, int]], bound_low: float | None = None, bound_up: float | None = None)
Parametrize with a single value the X coordinate of a group of support vertices.
Helpers¤
parameters
¤
combine_parameters
¤
combine_parameters(parrays: tuple[Float[Array, ...], ...], adef: Int[ndarray, parameters]) -> Float[Array, parameters]
Merge subarrays back into one flat array, inverting a split.
Parameters:
-
parrays(tuple[Float[Array, ...], ...]) –The subarrays to concatenate, in the order they were split.
-
adef(Int[ndarray, parameters]) –The permutation returned by :func:
split_parametersthat restores the original element order.
Returns:
-
parray(Float[Array, parameters]) –The recombined flat parameter array.
split_parameters
¤
split_parameters(parray: Float[Array, parameters], func: Callable[[Float[Array, parameters]], tuple[Shaped[ndarray, parameters], ...]]) -> tuple[list[Float[Array, ...]], Int[ndarray, parameters]]
Split a flat array into subarrays selected by a masking function.
Parameters:
-
parray(Float[Array, parameters]) –The flat parameter array to split.
-
func(Callable[[Float[Array, parameters]], tuple[Shaped[ndarray, parameters], ...]]) –A function returning one boolean mask per output subarray.
Returns:
reshape_parameters
¤
reshape_parameters(sarrays: Iterable[Float[Array, ...]], shapes: Iterable[tuple[int, ...]]) -> Iterator[Float[Array, ...]]
Reshape each flat array to its paired target shape.
Parameters:
-
sarrays(Iterable[Float[Array, ...]]) –The flat arrays to reshape.
-
shapes(Iterable[tuple[int, ...]]) –The target shape for each array, paired by position.
Yields:
-
array(Float[Array, ...]) –Each input array reshaped to its target shape.