Optimization through iteration - help!
Mostra commenti meno recenti
I'm desperatley trying to optimize vector x such as its sum equals one.I need this for an optimization problem which can only be solved by iteration.. Thx for any adivce
best Jan
x = [0.125,0.125,0.125,0.125];
testf = sum(x);
test1 = 1;
while abs(test1-testf)~=0
test1 = testf;
testf = sum(x*2);
end
9 Commenti
Geoff Hayes
il 7 Mag 2015
Jan - your above example for x already sums to one, so perhaps give a different x. Also, what rules can you apply to your array on each iteration of the loop so that it eventually sums to one? Can you add elements or remove them or scale them?
Jan Morawietz
il 7 Mag 2015
Geoff Hayes
il 7 Mag 2015
Hmm...I misread your original values and just realized now that sum(x*2) is 1.0 which means that you are finished on the first iteration of your while loop.
So if they can be scaled, do they all have to be scaled identically or can some elements increase or decrease independent of the others?
Jan Morawietz
il 7 Mag 2015
Geoff Hayes
il 7 Mag 2015
What other rules must you enforce? Presumably I can't just set the first element to one and the remaining to all zeros. Is each element constrained to a certain interval?
Jan Morawietz
il 7 Mag 2015
Jan Morawietz
il 7 Mag 2015
Geoff Hayes
il 8 Mag 2015
Jan - the code never resets the weight array so you will get the same answer on each iteration of the while loop. And multiplying the weights by a number less than one will mean that
sum(weight*0.2) < sum(weight)
always since each element of weight is less than one.
Jan Morawietz
il 8 Mag 2015
Risposte (1)
Thorsten
il 7 Mag 2015
x = 1/sum(x)*x;
3 Commenti
Jan Morawietz
il 7 Mag 2015
Modificato: Jan Morawietz
il 7 Mag 2015
Thorsten
il 8 Mag 2015
Hi Jan, yes, x is the weight vector. But why do you need an iteration when you can get the solution in one step? Is it homework?
Jan Morawietz
il 8 Mag 2015
Categorie
Scopri di più su Third-Party Cluster Configuration in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!