MCPcopy Create free account

hub / github.com/StanfordASL/neural-network-lyapunov / functions

Functions1,470 in github.com/StanfordASL/neural-network-lyapunov

↓ 219 callersMethodaddVars
@return new_vars_list A list of new variables.
neural_network_lyapunov/gurobi_torch_mip.py:402
↓ 128 callersMethodclone
(self)
neural_network_lyapunov/gurobi_torch_mip.py:113
↓ 86 callersMethodload
load from what was saved using the save method @param load_path string path to load dyn_learner from @param train_dataloader
neural_network_lyapunov/dynamics_learning.py:549
↓ 84 callersMethodstep_forward
Compute x[n+1] according to θ[n+1] = θ[n] + θ̇_dot[n]*dt when thetadot_as_input is true [pos_x[n+1], pos_y[n+1]] =
neural_network_lyapunov/examples/car/unicycle.py:135
↓ 78 callersMethodcheck_x
(self, mip_cnstr_return, x_val, s_val, alpha_val, is_satisfied)
neural_network_lyapunov/test/test_utils.py:153
↓ 69 callersMethodsetObjective
Set the linear objective. The objective is ∑ᵢ coeffs[i]ᵀ * variables[i] + constant @param coeffs A list of 1D pytorch tensors
neural_network_lyapunov/gurobi_torch_mip.py:1063
↓ 65 callersMethodaddMConstr
Add linear constraints sum_i A[i] * x[i] <=, == or >= b @param A. A list of pytorch tensors. @param x A list of lists. x[i] i
neural_network_lyapunov/gurobi_torch_mip.py:596
↓ 58 callersMethodaddLConstr
Add linear constraint. @param coeffs A list of 1D pytorch tensors. coeffs[i] are the coefficients for variables[i] @p
neural_network_lyapunov/gurobi_torch_mip.py:481
↓ 56 callersMethodadd_mixed_integer_linear_constraints
Given a MixedIntegerConstraintsReturn @p mip_cnstr_return, add the mixed-integer linear constraints to the program. We assume
neural_network_lyapunov/gurobi_torch_mip.py:681
↓ 51 callersMethodlyapunov_value
Compute the value of the Lyapunov function as V(x) = ReLU(x) - ReLU(x*) + λ|R*(x-x*)|₁ where |R*(x-x*)|₁ is the 1-norm of R*(
neural_network_lyapunov/lyapunov.py:160
↓ 36 callersMethodadd_mode
Add a new mode ẋ = Aᵢx+gᵢ if Pᵢx ≤ qᵢ @param Ai A x_dim * x_dim torch matrix. @param gi A x_dim torch array.
neural_network_lyapunov/hybrid_linear_system.py:417
↓ 33 callersMethodoutput_constraint
The output of (leaky) ReLU network is a piecewise linear function of the input. ReLU(x) = wₙᵀzₙ+bₙ s.t zᵢ₊₁ = max{0,
neural_network_lyapunov/relu_to_optimization.py:777
↓ 33 callersMethodsave
helper function to save relevant parameters @param save_path string for where to save (prefix)
neural_network_lyapunov/dynamics_learning.py:538
↓ 31 callersMethodnum_binary
(self)
neural_network_lyapunov/gurobi_torch_mip.py:109
↓ 31 callersMethodnum_slack
(self)
neural_network_lyapunov/gurobi_torch_mip.py:106
↓ 29 callersMethodcompute_objective_from_mip_data_and_solution
Suppose the MIP is solved to optimality. We then retrieve the active constraints from the (suboptimal) solution, together with the bi
neural_network_lyapunov/gurobi_torch_mip.py:958
↓ 25 callersMethodforward
(self, obs)
neural_network_lyapunov/examples/rl/td3.py:46
↓ 25 callersMethodlyapunov_derivative_as_milp
We assume that the Lyapunov function V(x) = ReLU(x) - ReLU(x*) + λ|R*(x-x*)|₁, where x* is the equilibrium state. In
neural_network_lyapunov/lyapunov.py:575
↓ 24 callersMethodtrain
(self, state_samples_all)
neural_network_lyapunov/train_lyapunov_barrier.py:889
↓ 23 callersMethodadd_lyapunov
Set the Lyapunov function to be trained. We will train a ReLU network, such that the function V(x) = ReLU(x) - ReLU(x*) + λ|R
neural_network_lyapunov/train_lyapunov_barrier.py:164
↓ 23 callersMethodmode
Returns the mode of x_start, u_start, namely self.P[mode] * (x_start, u_start) <= self.q[mode]. If x_start, u_start is on the
neural_network_lyapunov/hybrid_linear_system.py:297
↓ 21 callersMethodnum_input
(self)
neural_network_lyapunov/gurobi_torch_mip.py:103
↓ 21 callersMethodnum_out
(self)
neural_network_lyapunov/gurobi_torch_mip.py:50
↓ 21 callersMethodstep_forward
(self, x_start, u_start)
neural_network_lyapunov/relu_system.py:476
↓ 20 callersMethodR
(self)
neural_network_lyapunov/r_options.py:16
↓ 19 callersFunctioncheck_shape_and_type
(A, shape_expected, dtype_expected)
neural_network_lyapunov/utils.py:33
↓ 19 callersMethodlog
(self, name, value)
neural_network_lyapunov/dynamics_learning.py:386
↓ 19 callersMethodnum_eq
(self)
neural_network_lyapunov/gurobi_torch_mip.py:77
↓ 19 callersMethodnum_ineq
(self)
neural_network_lyapunov/gurobi_torch_mip.py:63
↓ 18 callersMethodforward
returns mean and log of variance in latent space as two tensors
neural_network_lyapunov/encoders.py:144
↓ 18 callersMethodstep
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model
neural_network_lyapunov/line_search_gd.py:129
↓ 17 callersMethodadd_mode
Add a new mode x[n+1] = Aᵢ*x[n] + Bᵢ*u[n] + cᵢ if Pᵢ * [x[n]; u[n]] <= qᵢ @param Ai A x_dim * x_dim torch matrix.
neural_network_lyapunov/hybrid_linear_system.py:94
↓ 17 callersFunctioncheck_mip_entry_grad
(entry_name, entry_index)
neural_network_lyapunov/test/feedback_gradient_check.py:185
↓ 17 callersMethodsolve
Solve the optimization in the documentation above. If the optimal cost is 0, then we find a Lyapunov function. Otherwise we minimizes
neural_network_lyapunov/simple_pwl_lyapunov.py:152
↓ 16 callersMethodadd_dynamics_mip_constraint_tester
(self, forward_system, controller_network, x_equilibrium,
neural_network_lyapunov/test/test_feedback_system.py:49
↓ 16 callersMethodadd_state_error_l1_constraint
This function is intended for internal usage only (but I expose it as a public function for unit test). we add the L1 loss |R
neural_network_lyapunov/lyapunov.py:92
↓ 15 callersMethod_add_node
(self, x_node: np.ndarray, parent_idx, cost_to_parent)
neural_network_lyapunov/examples/car/rrt_star.py:37
↓ 15 callersMethodstep_forward_test
(self, forward_system, controller_network, x, x_equilibrium, u_equilibrium, u_lower_
neural_network_lyapunov/test/test_feedback_system.py:502
↓ 15 callersMethodvalue
Compute the value of ϕ(x) - ϕ(x*) + c
neural_network_lyapunov/barrier.py:58
↓ 14 callersMethodadd_lyap_relu_output_constraint
This function is intended for internal usage only (but I expose it as a public function for unit test). Add the Lyapunov relu
neural_network_lyapunov/lyapunov.py:64
↓ 14 callersMethodcompute_alpha_index
Compute the index of α given an activation path (one and only one active ReLU unit on each layer). You could refer to output_gradient
neural_network_lyapunov/relu_to_optimization.py:896
↓ 14 callersMethoddynamics
(self, x, u)
neural_network_lyapunov/examples/rocket/rocket.py:21
↓ 14 callersMethodlyapunov_positivity_as_milp_tester
(self, system, relu, x_equilibrium, V_lambda, V_epsilon, R, x_val)
neural_network_lyapunov/test/test_lyapunov.py:850
↓ 13 callersFunctioncheck_mixed_integer_constraints
Solve the MIP by constraining x[n] and u[n], the solution x[n+1] should match with calling step_forward(x[n], u[n]).
neural_network_lyapunov/test/test_relu_system.py:207
↓ 13 callersMethoddynamics
Compute xdot of the unicycle.
neural_network_lyapunov/examples/car/unicycle.py:23
↓ 12 callersMethodcompute_u
The controller is defined as u[n] = ϕᵤ(x[n]) - ϕᵤ(x*) + u*
neural_network_lyapunov/feedback_system.py:442
↓ 12 callersMethodlyapunov_positivity_as_milp
For a ReLU network, in order to determine if the function V(x) = ReLU(x) - ReLU(x*) + λ * |R * (x - x*)|₁ where |R*(x - x*)|₁
neural_network_lyapunov/lyapunov.py:223
↓ 12 callersMethodmixed_integer_constraints
( self, u_lo=None, u_up=None)
neural_network_lyapunov/examples/pendulum/pendulum.py:167
↓ 12 callersMethodtotal_loss
Compute the total loss as the summation of 1. hinge(-V(xⁱ) + ε₂ |xⁱ - x*|₁) for sampled state xⁱ. 2. hinge(dV(xⁱ) + ε V(xⁱ))
neural_network_lyapunov/train_lyapunov_barrier.py:706
↓ 11 callersMethoddynamics
(self, x, u)
neural_network_lyapunov/examples/pole/pole.py:34
↓ 11 callersMethodset_variable_value
(self, R_val: np.ndarray)
neural_network_lyapunov/r_options.py:13
↓ 11 callersMethodstep
(self, action_np)
neural_network_lyapunov/examples/quadrotor2d/quadrotor2d_env.py:33
↓ 10 callersMethod_compute_layer_bound
Compute the input and output bounds of each ReLU neurons.
neural_network_lyapunov/relu_to_optimization.py:518
↓ 10 callersMethodadd_dynamics_mip_constraint_tester
(self, x_val)
neural_network_lyapunov/examples/quadrotor3d/test/test_quadrotor_feedback_system.py:47
↓ 10 callersMethodcheck_grad
(self, grad, grad_expected)
neural_network_lyapunov/test/test_utils.py:1198
↓ 10 callersMethodconcatenate_tester
(self, cnstr1, cnstr2, same_slack, same_binary, stack_output)
neural_network_lyapunov/test/test_gurobi_torch_mip.py:126
↓ 10 callersMethodset_option
(self, name, value)
neural_network_lyapunov/dynamics_learning.py:22
↓ 10 callersFunctionstack_matrix
(mat1, mat2, mat1_size, mat2_size)
neural_network_lyapunov/gurobi_torch_mip.py:184
↓ 9 callersMethoddynamics
(self, x, u)
neural_network_lyapunov/examples/pendulum/pendulum.py:23
↓ 9 callersMethoddynamics
Compute the continuous-time dynamics
neural_network_lyapunov/examples/quadrotor2d/quadrotor_2d.py:24
↓ 9 callersMethodfrom_mip_cnstr_return
(self, mip_cnstr_return: relu_to_optimization. ReLUMixedIntegerConstraintsReturn
neural_network_lyapunov/relu_system.py:32
↓ 9 callersMethodlyapunov_derivative_loss_at_samples
We will sample states xⁱ, i=1,...N, and we would like the Lyapunov function to decrease on these sampled states xⁱ. We denote l(x) as
neural_network_lyapunov/lyapunov.py:929
↓ 9 callersMethodlyapunov_loss_at_samples
computes lyapunov loss at the provided samples @param x_all tensor (num_samples, x/z dim) @param x_lo tensor upper bound outs
neural_network_lyapunov/dynamics_learning.py:327
↓ 9 callersMethodlyapunov_positivity_loss_at_samples
We will sample a state xⁱ, and we would like the Lyapunov function to be larger than 0 at xⁱ. Hence we define the loss as mea
neural_network_lyapunov/lyapunov.py:305
↓ 9 callersFunctionsetup_leaky_relu
(dtype, params=None, bias=True)
neural_network_lyapunov/test/test_lyapunov.py:54
↓ 9 callersMethodstrengthened_constraint_tester
(self, c, w, b, lo, up, relu_input_lo, relu_input_up, ideal, selective)
neural_network_lyapunov/test/test_mip_utils.py:531
↓ 9 callersMethodtrain_lyapunov_on_samples
Train a ReLU network on given state samples (not the adversarial states found by MIP). The loss function is the weighted sum of the l
neural_network_lyapunov/train_lyapunov_barrier.py:992
↓ 8 callersFunctioncheck_add_dynamics_constraint
(dut, x_val, u_val, atol=0, rtol=1E-7)
neural_network_lyapunov/test/test_relu_system.py:261
↓ 8 callersMethodlyapunov_derivative
Compute the Lyapunov derivative condition V(x[n+1]) - V(x[n]) + εV(x[n]) where the Lyapunov function is V(x) = ϕ(x) −
neural_network_lyapunov/lyapunov.py:551
↓ 8 callersMethodnonempty_constraint_tester
(self, c, w, b, lo, up, index_sets, xhat)
neural_network_lyapunov/test/test_mip_utils.py:261
↓ 8 callersMethodstep_forward
Compute the next state as pos[n+1] = pos[n] + (pos_dot[n] + pos_dot[n+1]) / 2 * dt (rpy[n+1], pos_dot[n+1]-pos_dot[n], angula
neural_network_lyapunov/examples/quadrotor3d/quadrotor.py:426
↓ 7 callersMethod__init__
Parent class for encoders. Encoders should be child classes of this class and implement the forward method (which takes a tensor
neural_network_lyapunov/encoders.py:6
↓ 7 callersMethodconstruct_relu_system_example
(self, discrete_time_flag)
neural_network_lyapunov/test/test_relu_system.py:724
↓ 7 callersMethodconstruct_relu_system_example
(self, discrete_time_flag)
neural_network_lyapunov/test/test_relu_system.py:814
↓ 7 callersMethodevaluator
(v)
neural_network_lyapunov/test/test_r_options.py:90
↓ 7 callersMethodpossible_dx
TODO(hongkai.dai): I will deprecate this function soon. But for now I keep it for backward maintanence as other systems in relu_syste
neural_network_lyapunov/examples/car/unicycle.py:184
↓ 7 callersMethodsaturation_tester
(self, lower_limit, upper_limit, input_lower_bound, input_upper_bound, x_val, y_val)
neural_network_lyapunov/test/test_utils.py:676
↓ 7 callersFunctionsetup_relu
(dtype, params=None)
neural_network_lyapunov/test/test_lyapunov.py:19
↓ 7 callersMethodtrain_adversarial
We solve the MILP as verifier. If the MILP finds counter-examples, we add the counter-examples to the training set (with a maximal bu
neural_network_lyapunov/train_lyapunov_barrier.py:1232
↓ 7 callersFunctionurdf_path
(file)
neural_network_lyapunov/worlds.py:7
↓ 7 callersMethodvariables
(self)
neural_network_lyapunov/r_options.py:19
↓ 6 callersMethod_compute_network_output_bounds
(self, previous_neuron_input_lo,
neural_network_lyapunov/relu_to_optimization.py:608
↓ 6 callersMethod_construct_milp_for_roa
This is the internal function to formulate an MILP for computing the region of attraction (ROA). Refer to compute_region_of_attractio
neural_network_lyapunov/lyapunov.py:1133
↓ 6 callersFunction_get_R
Take matrix R used in the 1-norm |R*(x-x*)|₁.
neural_network_lyapunov/lyapunov.py:1262
↓ 6 callersMethod_lyapunov_gradient
Compute the gradient ∂V/∂x. When the gradient is not unique, we return all the left and right gradient.
neural_network_lyapunov/lyapunov.py:492
↓ 6 callersMethodadd_state_error_l1_constraint_tester
(self, system, relu, x_equilibrium, x_val, R, binary_for_zero_inp
neural_network_lyapunov/test/test_lyapunov.py:364
↓ 6 callersFunctionblk_diagonize_matrix
(mat1, mat2, num_cnstr1, num_cnstr2, num_var1, num_var2)
neural_network_lyapunov/gurobi_torch_mip.py:196
↓ 6 callersMethodconstruct_lyap1
(self, discrete_time_flag)
neural_network_lyapunov/test/test_train_feedback_system.py:405
↓ 6 callersMethodconstruct_milp_roa_tester
(self, dut, x_curr_in_box, is_milp_feasible)
neural_network_lyapunov/test/test_lyapunov_roa.py:76
↓ 6 callersMethodextend_node
From a given node, try to forward simulate the states with many sampled control actions for time dt, and then return the state with t
neural_network_lyapunov/examples/car/rrt_star.py:96
↓ 6 callersMethodflight_phase_energy
Compute the total kinetic + potential energy for a flight phase state.
neural_network_lyapunov/spring_loaded_inverted_pendulum.py:128
↓ 6 callersMethodget_active_constraints
Pick out the active constraints on the continuous variables as A_act * r = b_act @param active_ineq_row_indices A set of indi
neural_network_lyapunov/gurobi_torch_mip.py:847
↓ 6 callersMethodget_random_samples
@param n Integer number of samples @return rand_data Tensor with random initial states @return rand_label Tensor with corresp
neural_network_lyapunov/train_value.py:134
↓ 6 callersMethodlyapunov_derivative_loss_at_samples_and_next_states
We will sample states xⁱ, i=1,...N, and we would like the Lyapunov function to decrease on these sampled states xⁱ. We denote l(x) as
neural_network_lyapunov/lyapunov.py:990
↓ 6 callersMethodlyapunov_loss
compute the Lyapunov losses @param lyap_pos_threshold float the thresold used when computing an adversarial example for viola
neural_network_lyapunov/dynamics_learning.py:194
↓ 6 callersMethodminkowski_sum_tester
(self, x, y)
neural_network_lyapunov/test/test_utils.py:1390
↓ 6 callersMethodrollout
generates a rollout with the learned dynamics for N step @param x_init tensor of dim x_dim @param N int number of steps to ta
neural_network_lyapunov/dynamics_learning.py:579
↓ 6 callersMethodsetup_mixed_integer_constraints_return
(self)
neural_network_lyapunov/test/test_gurobi_torch_mip.py:1020
↓ 6 callersFunctionsetup_trecate_discrete_time_system
The piecewise affine system is from "Analysis of discrete-time piecewise affine and hybrid systems" by Giancarlo Ferrari-Trecate et.al.
neural_network_lyapunov/test/test_hybrid_linear_system.py:10
↓ 6 callersMethodstate_distance
(self, x1, x2)
neural_network_lyapunov/examples/car/rrt_star.py:80
next →1–100 of 1,470, ranked by callers