Vista Previa de la Imagen

function [observation, reward, isDone] = step(this, action)
            disp('Step function called');
            isDone = false;
           
            this.UEPositions = this.updateUEPositions(this.UEPositions, this.UEVelocities);
            this.UEPositions = this.limitUEPositions(this.UEPositions, this.SimArea);
            
            for i = 1:this.NumUE
                if action(i) == 0
                    % Keep the current connection
                    reward = reward + 1;
                else
                    distances = sqrt(sum((this.BSPositions - this.UEPositions(i, :)).^2, 2));
                    [~, minIndex] = min(distances);
                    disp(minIndex);
                    if this.timestep > 1 && this.UEBSConnections(i, this.timestep-1) ~= minIndex
                        this.UEBSConnections(i, this.timestep) = minIndex;
                        reward = reward - 1; % Penalty for handover
                    end

Prompt: function [observation, reward, isDone] = step(this, action) disp('Step function called'); isDone = false; this.UEPositions = this.updateUEPositions(this.UEPositions, this.UEVelocities); this.UEPositions = this.limitUEPositions(this.UEPositions, this.SimArea); for i = 1:this.NumUE if action(i) == 0 % Keep the current connection reward = reward + 1; else distances = sqrt(sum((this.BSPositions - this.UEPositions(i, :)).^2, 2)); [~, minIndex] = min(distances); disp(minIndex); if this.timestep > 1 && this.UEBSConnections(i, this.timestep-1) ~= minIndex this.UEBSConnections(i, this.timestep) = minIndex; reward = reward - 1; % Penalty for handover end

Creado en: 8/29/2024, 8:00:29 AM