Back to Projects

Adaptive Neural Control Systems

Adaptive Neural Control Demo

Project Overview

This project explores the design, simulation, and analysis of adaptive neural network-based control systems for nonlinear dynamic processes using MATLAB and Simulink. The aim was to develop a controller that can adjust its behavior in real time to handle uncertainties and nonlinearity—challenges where conventional fixed controllers struggle. By integrating a neural network within the feedback loop, the controller is designed to learn the system dynamics on the fly, thereby improving performance without extensive manual re-tuning.

Key Features

Development Process & Challenges

  1. Theoretical Foundation: The project started with a review of adaptive control theory. We derived a Lyapunov function candidate and an online weight update law for the neural network controller. This provided a framework to ensure stability even as the network learned.
  2. MATLAB/Simulink Implementation: The adaptive controller was implemented entirely in MATLAB. Simulink was used to model the nonlinear system and integrate the controller. Custom MATLAB functions handled the neural network’s forward pass and weight update.
  3. Simulation and Tuning: Extensive simulations were run on an inverted pendulum model. Challenges included selecting an appropriate learning rate—the balance between rapid adaptation and avoiding instability was critical. Iterative testing helped in fine-tuning the parameters.
  4. Handling Noise and Uncertainty: Although the project focused on the controller design, we also simulated scenarios with sensor noise and parameter variations to test the robustness of the adaptive controller.

Technologies Used

Achievements & Metrics

Technical Architecture

Neural Controller Design

classdef AdaptiveNeuralController < handle
    properties
        % Network parameters
        W1  % Input layer weights
        W2  % Hidden layer weights
        b1  % Input bias
        b2  % Hidden bias
        
        % Learning rates
        eta1 = 0.01
        eta2 = 0.02
        
        % Stability parameters
        gamma = 0.5
        sigma = 0.1
    end
    
    methods
        function obj = AdaptiveNeuralController(input_dim, hidden_dim)
            % Initialize weights and biases
            obj.W1 = randn(hidden_dim, input_dim) * sqrt(2/input_dim);
            obj.W2 = randn(1, hidden_dim) * sqrt(2/hidden_dim);
            obj.b1 = zeros(hidden_dim, 1);
            obj.b2 = 0;
        end
        
        function u = computeControl(obj, x, xd)
            % Compute control input
            z = obj.W1 * x + obj.b1;
            h = tanh(z);
            u = obj.W2 * h + obj.b2;
            
            % Update weights using Lyapunov-based adaptation
            e = x - xd;
            obj.updateWeights(e, h, x);
        end
    end
end

Implementation Details

Stability Analysis

function V = lyapunovFunction(e, W_tilde, gamma)
    % Compute Lyapunov function
    V = 0.5 * e' * e + ...
        0.5/gamma * trace(W_tilde' * W_tilde);
    
    % Compute derivative
    V_dot = e' * (-K*e + W_tilde'*phi(x)) + ...
            1/gamma * trace(W_tilde'*(-gamma*phi(x)*e'));
    
    % Ensure stability
    assert(V_dot <= 0, 'Stability condition violated');
end

Outputs

Resources