Bardo.Utils (Bardo v0.1.0)
View SourceUtility functions for the Bardo system.
Summary
Functions
Return correct module syntax based on SDK environment configuration.
Seed PRNG for the current process.
Generate a random string of the specified length.
Safely convert binary to Erlang term.
Safely serialize Erlang term to binary.
Saturate a value between a minimum and maximum limit.
Return system metrics.
Checks if vector A dominates vector B with a minimum improvement percentage.
Calculate vector difference with minimum improvement percentage (MIP).
Functions
Return correct module syntax based on SDK environment configuration.
Seed PRNG for the current process.
Uses exs1024s (not cryptographically strong, but fast).
@spec random_string(non_neg_integer()) :: String.t()
Generate a random string of the specified length.
Parameters
length
- The length of the random string to generate
Returns
- A random string of the specified length
Safely convert binary to Erlang term.
Safely serialize Erlang term to binary.
Saturate a value between a minimum and maximum limit.
Examples
iex> Bardo.Utils.sat(1.5, 1.0)
1.0
iex> Bardo.Utils.sat(-1.5, 1.0)
-1.0
iex> Bardo.Utils.sat(0.5, 1.0)
0.5
@spec system_metrics() :: map()
Return system metrics.
Checks if vector A dominates vector B with a minimum improvement percentage.
Returns true if all elements in A are significantly better than in B.
Calculate vector difference with minimum improvement percentage (MIP).