Маршрутизация И Нейронная Сеть Хопфилда

Тема в разделе "Свободное общение", создана пользователем ergonom, 19 окт 2011.

Статус темы:
Закрыта.
  1. ergonom

    ergonom Гость

    Помогите решить задачу.
    Задача.
    Есть нейронная сеть Хпфилда которая решает задачу маршрутизации с использованием формулы Парк и Чои.
    Я написал программу на матлабе, но маршрут она не находит.
    Помогите советом или программой.

    %
    %алгоритм Прак Чои
    clear all;
    clc;
    close all; %закрывает фигуры
    N=5;
    %веса связей
    U=rand(N,N);
    m1=0;
    m2=0;
    m3=0;
    m4=0;
    m5=0

    tao=1;

    mu1=950;
    mu2=2500;
    mu3=1900;
    mu4=100;
    mu5=500;

    a=50;
    %шаг пересчета
    lamda=0.0001;

    %координаты городов
    % routx=[0.4,0.2439,0.1707,0.2293,0.5171];
    % routy=[0.4439,0.1463,0.2293,0.761,0.9414];
    routx=[0.4,0.2439,0.1707,0.2293,0.5171,0.8732,0.6878,0.8488,0.6683,0.6195,0.9125
    ];
    routy=[0.4439,0.1463,0.2293,0.761,0.9414,0.6536,0.5219,0.3609,0.2536,0.2634, 0.9568];
    % plot(routx,routy,'ro','Color','b');
    for i=1:1:N
    for j=1:1:N
    % матрица стоимости маршрута
    c(i,j)=sqrt((routx(i)-routx(j))^2+(routy(i)-routy(j))^2);
    end
    end

    %рисуем полносвязный граф сети
    for m = 1:1:N
    for n = m+1:1:N
    line ([routx(m) ], [routy(m) ],'Color','b', 'Marker','o');
    if c(m,n)>0
    line ([routx(m) routx(n)], [routy(m) routy(n)],'Color','b','Marker','o');
    end
    end
    end


    % V=rand(N,N);
    %расчет значений выхода нейронов
    for i=1:1:N
    for j=1:1:N
    V(i,j)=1/(1+ exp(-a*c(i,j)));
    end
    end
    V
    %задаем матрицу гамма
    for i=1:1:N
    for j=1:1:N
    if(c(i,j)>0)
    gammma(i,j)=0;%p
    else
    gammma(i,j)=1;%p
    end

    end
    end

    %узел источник
    s=1;
    s
    %узел назначения
    d=5;
    d
    %задаем матрицу fi

    for i=1:1:N
    if i==s
    fii(i)=1;
    elseif i==d
    fii(i)=-1;

    else fii(i)=0;

    end

    end

    p=1;
    x(p)=p;
    y(p)=0;

    for i=1:1:N
    for j=1:1:N
    y(p)=y(p)+V(i,j)*c(i,j);
    end
    end
    Vst= -V;
    % Vst


    while Vst~=V
    Vst
    V
    p=p+1;
    m1=0;
    m2=0;
    m3=0;
    m4=0;
    m5=0;

    U
    for i=1:1:N
    for j=1:1:N

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    m1=0;
    m11=0;
    if i~=j

    for ii=1:1:N
    for jj=1:1:N
    if jj~=i
    for k=1:1:N
    if k~=i

    m11=m11+1-c(i,k)
    end
    end

    end
    m1=m1+m11+c(i,j);
    end
    end

    end
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    m2=0;
    if i~=j
    for ii=1:1:N
    for jj=1:1:N
    if jj~=i
    m2=m2+gammma(ii,jj);
    end
    end
    end

    end

    % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    m3=0;
    m31=0;
    if i~=j
    for ii=1:1:N
    for jj=1:1:N
    if jj~=i
    m31=m31+V(ii,jj)-V(jj,ii);
    end
    end
    end
    end
    m3=2*m31-2*fii(i);

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    m4=0;
    if i~=j
    for ii=1:1:N
    for jj=1:1:N
    if jj~=i
    m4=m4+1-V(ii,jj);
    end
    end
    end
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    m5=0;
    for k=1:1:N
    if k~=i
    m5=m5+V(k,i);
    end

    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    Udao(i,j)=-U(i,j)/tao-m1*mu1-m2*mu2-m3*mu3-m4*mu4-m5*mu5;
    % Udao(i,j)=-U(i,j)/tao-m1*mu1/2-m2*mu2/2-m3*mu3/2-m4*mu4/2-m5*mu5/2;
    end
    end

    Vst=V;
    % U
    U=U+lamda*Udao;

    %расчет выходных значений нейронjd
    for ii=1:1:N
    for jj=1:1:N

    V(ii,jj)=1/(1+exp(-a*U(ii,jj)));
    end
    end

    %пересчет выходов нейронов в пространство 0 1
    % for ux=1:1:N
    % for ui=1:1:N
    % if V(ux,ui)<0.3
    % V(ux,ui)=0;
    % end
    % if V(ux,ui)>0.7
    % V(ux,ui)=1;
    % end
    % end
    % end
    %V = round(V);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%пересчет учета функции энергии
    V
    x(p)=p;
    y(p)=0;
    for i=1:1:N
    for j=1:1:N
    y(p)=y(p)+V(i,j)*c(i,j);
    end
    end


    end

    V = round(V);
    V
    %рисуем маршрут на графе
    for m = 1:1:N
    for n = m+1:1:N
    % line ([routx(m) ], [routy(m) ], 'Color','r','Marker','o');
    if V(m,n)>=1
    line ([routx(m) routx(n)], [routy(m) routy(n)],'Color','r', 'Marker','o');
    end
    end
    end

    figure

    plot(x,y,'r-','Color','c');
     
Загрузка...
Похожие Темы - Маршрутизация Нейронная Сеть
  1. RZX
    Ответов:
    3
    Просмотров:
    2.789
  2. XiNoID
    Ответов:
    8
    Просмотров:
    3.799
Статус темы:
Закрыта.

Поделиться этой страницей