Решение задачи повышения надежности резервирования с помощью эволюционного моделирования

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование



?ие значений целевых функцийSelectPopulation (var Pop: TPopulation; var tempPop: TPopulation);

//формирование временной популяции выбором из двухSelectPopulation2 (var Pop: TPopulation; var tempPop: TPopulation);

//формирование временной популяции выбором из трехCrossPopulation (var TempPop: TPopulation; var TempPopCr: TPopulation);

//скрещивание индивидов популяцииMutantPopulation (var TempPop: TPopulation);

//мутация популяцииFixPopulation (var TempPop: TPopulation);

//исправление популяцииInitTavg;

//вычисление T-среднегоSumTxX (var Indiv: TIndivid): real;

//вычисление левой части ограничения по времениInitRecord;

//задание рекордного массива начальными числамиAddToRecord (var TempPop: TPopulation);

//изменение рекордного множества при появлении новой популяцииCopyPopulation (var PopFrom: TPopulation; var PopInto: TPopulation);

//копирование популяцийInitRec;

//инициализация рекордного множестваEraseRec;

//удаление рекордного множестваInitInputArrays;

//инициализация входных массивовEraseInputArrays;

//удаление входных массивовGetS (var II: TIndivid): real;

//определение стоимости по решениюGetP (var II: TIndivid): real;

//определение вероятности по решениюGetS (var II: TIndivid): real;j: integer;:= 0;j := 0 to N-1 doII[j] of

: result := result + S[j];

: result := result + 2 * S[j] * G[j];

: result := result + 4 * S[j];;;GetP (var II: TIndivid): real;j: integer;:= 1;j := 0 to N-1 doII[j] of

: result := result * P[j];

: result := result * (2*P[j]-P[j]*P[j]);

: result := result * (3*P[j]*P[j]-2*P[j]*P[j]*P[j]);;;CountFitness (var Pop: TPopulation);i,j: integer;i := 0 to L-1 do.Fitness[i].S := -GetS(Pop.Individs[i]);.Fitness[i].P := GetP(Pop.Individs[i]);;;InitPopulation (var Pop: TPopulation);i,j: integer;

//randomize; //задаем длину(Pop.Individs, L);(Pop.Fitness, L);(Pop.Rank, L);

//присваиваем случайные значенияi := 0 to L-1 do(Pop.Individs[i],N);j := 0 to N-1 do.Individs[i][j] := random(3)+1;;

//исправляем популяцию(Pop);

=r;:=j-1;Euc[j].distance k) and (pos( + IntToStr(k) + ,str)=0) then(Pop.Fitness[index].S<=Pop.Fitness[k].S) and (Pop.Fitness[index].P <= Pop.Fitness[k].P) and

((Pop.Fitness[index].S<Pop.Fitness[k].S) or (Pop.Fitness[index].P < Pop.Fitness[k].P))then:= false;;RankPopulation (var Pop: TPopulation);Scur, Stotal: string;: integer;: integer;: integer;: integer;: TEucArray;: integer;: integer;: integer;i := 0 to L-1 do.Fitness[i].S := -GetS(Pop.Individs[i]);.Fitness[i].P := GetP(Pop.Individs[i]);.Rank[i] := 0;;:= ;:= 1;

//выбрать недоминируемые элементы и присвоить им ранг:= 0;:= ;i := 0 to L-1 dopos( +IntToStr(i)+ ,Stotal)=0 thenIndivIsNotDominated(Pop, i, Stotal) then:= Scur + IntToStr(i) + ;.Rank[i] := r;(NumsInStr);;

0 then[t].index := k;(t);;k := 0 to m-1 do //считаем расстрояния[k].distance := 0;t := 0 to m-1 do[k].distance := EucArr[k].distance +(sqr(Pop.Fitness[EucArr[k].index].S-Pop.Fitness[EucArr[t].index].S) +(Pop.Fitness[EucArr[k].index].P-Pop.Fitness[EucArr[t].index].P));;(EucArr, 0, m-1); //сортируемk := 0 to m-1 do.Rank[EucArr[k].index] := r +(m-k-1)/m; //записываем ранки:= nil; //удаляем массив:= Stotal + Scur;(r);">//m := length(Scur); //создаем массив текущего ранга !!!!!!!!!!!!!:= NumsInStr;(EucArr, m);:= 0;k := 0 to L-1 dopos( +inttostr(k)+ ,Scur)<>0 then[t].index := k;(t);;k := 0 to m-1 do //считаем расстрояния[k].distance := 0;t := 0 to m-1 do[k].distance := EucArr[k].distance +(sqr(Pop.Fitness[EucArr[k].index].S-Pop.Fitness[EucArr[t].index].S) +(Pop.Fitness[EucArr[k].index].P-Pop.Fitness[EucArr[t].index].P));;(EucArr, 0, m-1); //сортируемk := 0 to m-1 do.Rank[EucArr[k].index] := r +(m-k-1)/m; //записываем ранки:= nil; //удаляем массив:= Stotal + Scur;(r);

(length(Scur)=1) or (r>L+2);

//после этого r - maxrank

= Pop.Rank[t2] thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t1][j];.Fitness[i].S := pop.Fitness[t1].S;.Fitness[i].P := Pop.Fitness[t1].P;.Rank[i] := Pop.Rank[t1]j := 0 to N-1 do.Individs[i][j] := Pop.Individs[t2][j];.Fitness[i].S := pop.Fitness[t2].S;.Fitness[i].P := Pop.Fitness[t2].P;.Rank[i] := Pop.Rank[t2];;;SelectPopulation2 (var Pop: TPopulation; var tempPop: TPopulation);i,j: integer;, t2, t3: integer; //индексы выбранных особейi := 0 to L-1 do:= random (L);:= random (L);:= random (L);(Pop.Rank[t1] >= Pop.Rank[t2]) and (Pop.Rank[t1] >= Pop.Rank[t3]) thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t1][j];.Fitness[i].S := pop.Fitness[t1].S;.Fitness[i].P := Pop.Fitness[t1].P;.Rank[i] := Pop.Rank[t1](Pop.Rank[t2] >= Pop.Rank[t1]) and (Pop.Rank[t2] >= Pop.Rank[t3]) thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t2][j];.Fitness[i].S := pop.Fitness[t2].S;.Fitness[i].P := Pop.Fitness[t2].P;.Rank[i] := Pop.Rank[t2]j := 0 to N-1 do.Individs[i][j] := Pop.Individs[t3][j];.Fitness[i].S := pop.Fitness[t3].S;.Fitness[i].P := Pop.Fitness[t3].P;.Rank[i] := Pop.Rank[t3];;CrossPopulation (var TempPop: TPopulation; var TempPopCr: TPopulation);i,j: integer;, t2: integer;: integer;//crossover point: 1..3;">//преобразовываем рангi:= 0 to L-1 do.Rank[i] := r + Pop.Rank[i] - 2 * trunc(Pop.Rank[i]) - 1;;SelectPopulation (var Pop: TPopulation; var TempPop: TPopulation);i,j: integer;, t2: integer; //индексы выбранных особейi := 0 to L-1 do:= random (L);:= random (L);Pop.Rank[t1] >= Pop.Rank[t2] thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t1][j];.Fitness[i].S := pop.Fitness[t1].S;.Fitness[i].P := Pop.Fitness[t1].P;.Rank[i] := Pop.Rank[t1]j := 0 to N-1 do.Individs[i][j] := Pop.Individs[t2][j];.Fitness[i].S := pop.Fitness[t2].S;.Fitness[i].P := Pop.Fitness[t2].P;.Rank[i] := Pop.Rank[t2];;;SelectPopulation2 (var Pop: TPopulation; var tempPop: TPopulation);i,j: integer;, t2, t3: integer; //индексы выбранных особейi := 0 to L-1 do:= random (L);:= random (L);:= random (L);(Pop.Rank[t1] >= Pop.Rank[t2]) and (Pop.Rank[t1] >= Pop.Rank[t3]) thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t1][j];.Fitness[i].S := pop.Fitness[t1].S;.Fitness[i].P := Pop.Fitness[t1].P;.Rank[i] := Pop.Rank[t1](Pop.Rank[t2] >= Pop.Rank[t1]) and (Pop.Rank[t2] >= Pop.Rank[t3]) thenj := 0 to N-1 do.Individs[i][j] := Pop.Individs[t2][j];.Fitness[i].S := pop.Fitness[t2].S;.Fitness[i].P := Pop.Fitness[t2].P;.Rank[i] := Pop.Rank[t2]j := 0 to N-1 do.Individs[i][j] := Pop.Individs[t3][j];.Fitness[i].S := pop.Fitness[t3].S;.Fitness[i].P := Pop.Fitness[t3].P;.Rank[i] := Pop.Rank[t3];;CrossPopulation (var TempPop: TPopulation; var TempPopCr: TPopulation);i,j: integer;, t2: integer;: integer;//crossover point: 1..3;

0thenj:=0toN-1do.Individs[L-1][j]:=TempPop.Individs[t1][j];;MutantPopulation(varTempPop:TPopulation);i,j:integer;:integer;">{for i := 0 to (L div 2) dorandom(101)/100 0 thenj := 0 to N-1 do.Individs[L-1][j]:=TempPop.Individs[t1][j];;MutantPopulation (var TempPop: TPopulation);i,j: integer;: integer;

{for i := 0 to L-1 doj := 0 to N-1 dorandom(101)/100 <= Pmut then.Individs[i][j]