How to improve elements of a weight array related to a matrix using weighted sampling without replacement?
    3 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have a 4 by 12 matrix (M) as a solution for a recursive function (f). f(M) = fitness where fitness is a real number. In each iteration of an optimization algorithm, some elements in M would change in order to maximize the fitness. The selection of the elements is through weighted sampling by datasample. So we have a 4 by 12 array as weight matrix (W), which has equal elements at the very beginning (e.g., W=ones(4,12); ). In each iteration, after assessing the new solution by the fitness function, the weight matrix should be updated according to the effect of the elements' changes on the fitness. If those elements improve the fitness, the related weight should increase; otherwise, it should be decreased.
Assume that we have M_1 (as the parent) and W_1 and fit_1 as initial parameters. In the first iteration, after weighted sampling from M_1, we make some changes, so we have M_2 (as offspring) and fit_2. I'm looking for a way to update the W_1 according to the change rate. Attached please find my code. I think that at the end of run, W(4,:) should be larger than W(1,:) according to the Benefit matrix.
Any idea for optimizing the code would be appreciated.
Here is a kind of simple pseudo-code that I hope it can help:
M = randi([0.5,8],4,12);
W = ones(4,12);
f = @(x) x.^2;
fit_1 = f(M);
for i =1:1000
	[~,ind] = datasample(M,2,'Replace',false,'Weights',W)
	M_offspring = Update (M(ind)) using a function
	fit_2 = f(M_offspring)
	if fit_2 > fit_1
            W (ind) = get award (increase)
    	else
            W (ind) = get penalty (decrease)
    	end
	fit_1 = fit_2
	M = M_offspring
end
4 Commenti
  darova
      
      
 il 24 Apr 2020
				Don't know, maybe becauses of a lot of explanations. I like questions as following

Is it possible to simplify your question to see something like that?
Risposte (0)
Vedere anche
Categorie
				Scopri di più su Surrogate Optimization in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

