English, asked by arunaanbu333, 1 year ago

i need quick reduct algorithm with matlab coding...


abhinavmishra1: i will give your answer just a minute
sukhetha: I hope this was helpful even though your question

Answers

Answered by sukhetha
0
 the following code works 
     ⇒scennum_fav is the favored scenario number after reduction
         scennum_fav=250;
     ⇒Initial scenario numbers, my matrix to be reduced is CO2_scen [1000x234]
         scennum_int=size(CO2_scen,1);

      ⇒In the beginning all scenarios are equiprobable
        scenprob=ones(scennum_int,1)*1/scennum_int;
      ⇒scenario reduciton algorithm
       while size(CO2_scen,1)>scennum_fav

      ⇒ Calculate euclidean distances

      dist_mat = queeze(sqrt(sum(bsxfun(@minus,CO2_scen,reshape       (CO2_scen',1,size(CO2_scen,2),size(CO2_scen,1))).^2,2)));
          dist_mat(~dist_mat)=inf;
        row_min = min(dist_mat);
        min_value = min (row_min);

[row column]= find(dist_mat==min_value); % shows the position of the minimum element, r= which row and c= which column

⇒Remove scenario with smallest distance and adding its probability to reference      scenario (the scenario to be removed is independent of its probability)

if scenprob(row(1))>scenprob(row(2))
            CO2_scen(row(2),:)=[];
            scenprob(row(1),:)=scenprob(row(1),:)+scenprob(row(2),:);
            scenprob(row(2),:)=[];
        elseif scenprob(row(1))<scenprob(row(2))
            CO2_scen(row(1),:)=[];
            scenprob(row(2,:))=scenprob(row(2,:))+scenprob(row(1,:));
            scenprob(row(1),:)=[];
        else
            CO2_scen(row(2),:)=[];
            scenprob(row(1,:))=scenprob(row(1,:))+scenprob(row(2,:));
            scenprob(row(2),:)=[];
        end
    end
 
















Similar questions