feat(python): implement python bindings for all components and solvers
This commit is contained in:
@@ -175,7 +175,7 @@ impl ControlMapping {
|
||||
///
|
||||
/// Manages constraint-to-control-variable mappings for embedding constraints
|
||||
/// into the residual system.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct InverseControlConfig {
|
||||
/// Mapping from constraint ID to control variable ID.
|
||||
constraint_to_control: HashMap<ConstraintId, BoundedVariableId>,
|
||||
@@ -183,15 +183,28 @@ pub struct InverseControlConfig {
|
||||
control_to_constraint: HashMap<BoundedVariableId, ConstraintId>,
|
||||
/// Whether inverse control is enabled globally.
|
||||
enabled: bool,
|
||||
/// Finite difference epsilon for numerical Jacobian computation.
|
||||
/// Default is 1e-6, which balances numerical precision against floating-point rounding errors.
|
||||
finite_diff_epsilon: f64,
|
||||
}
|
||||
|
||||
impl Default for InverseControlConfig {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl InverseControlConfig {
|
||||
/// Default finite difference epsilon for numerical Jacobian computation.
|
||||
pub const DEFAULT_FINITE_DIFF_EPSILON: f64 = 1e-6;
|
||||
|
||||
/// Creates a new empty inverse control configuration.
|
||||
pub fn new() -> Self {
|
||||
InverseControlConfig {
|
||||
constraint_to_control: HashMap::new(),
|
||||
control_to_constraint: HashMap::new(),
|
||||
enabled: true,
|
||||
finite_diff_epsilon: Self::DEFAULT_FINITE_DIFF_EPSILON,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,9 +214,25 @@ impl InverseControlConfig {
|
||||
constraint_to_control: HashMap::new(),
|
||||
control_to_constraint: HashMap::new(),
|
||||
enabled: false,
|
||||
finite_diff_epsilon: Self::DEFAULT_FINITE_DIFF_EPSILON,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the finite difference epsilon used for numerical Jacobian computation.
|
||||
pub fn finite_diff_epsilon(&self) -> f64 {
|
||||
self.finite_diff_epsilon
|
||||
}
|
||||
|
||||
/// Sets the finite difference epsilon for numerical Jacobian computation.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if epsilon is non-positive.
|
||||
pub fn set_finite_diff_epsilon(&mut self, epsilon: f64) {
|
||||
assert!(epsilon > 0.0, "Finite difference epsilon must be positive");
|
||||
self.finite_diff_epsilon = epsilon;
|
||||
}
|
||||
|
||||
/// Returns whether inverse control is enabled.
|
||||
pub fn is_enabled(&self) -> bool {
|
||||
self.enabled
|
||||
|
||||
Reference in New Issue
Block a user