Optimization Toolbox Genetic algorithm
7 views (last 30 days)
Show older comments
Azime Beyza Ari
on 13 Mar 2022
Commented: Azime Beyza Ari
on 14 Mar 2022
hello everyone, I am currently working on a maximum coverage problem and i would like to solve it with genetic algorithm solver. But i am having trouble. I am using live editor and in the parameters and data section i calculated some values that i want to use in my objective function. In the same page i have objective function space where i can write my function. But the values i previously calculated in the data section is seem to be not recognized by the function below. So any suggestions on how to solve this problem?
thank you in advance.
0 Comments
Accepted Answer
Benjamin Thompson
on 13 Mar 2022
The Live Editor has diferent types of "Run" functions. You probably want "Run" all instread of running a single section. Or if you are talking about the input controls like a slider, right click each control and make sure the options match your requirements. There are usually some options like when the control value changes does it just run the current section, the current section and everything after, or curren section and everything before. If you can post the code that would help give a better answer.
11 Comments
Benjamin Thompson
on 14 Mar 2022
It does not look like the Optimize task for Live Editor is meant for matrix-valued inputs. It does not generate anything for the lb lower bound argument to ga other than zeros(V, 1). And if you try setting V to 36x36 to make the problem two-dimensional the call to zeros fails.
Maybe you leave xij as a 1296x1 vector as the input to objectivefunct and in objectivefunct you convert to a temporary 36x36 matrix for your calculation, like this:
function z = objectivefunct(ai, rij,xij)
temp = reshape(xij,36,36);
for i = 1:36
for j = 1:36
z = (-1)*(ai(i,1)*temp(i,j)*rij(i,j));
end
end
end
This seem to run and do something at least. Hopefully it is doing what you want.
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!