Optimization Toolbox Genetic algorithm

4 次查看(过去 30 天)
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.

采纳的回答

Benjamin Thompson
Benjamin Thompson 2022-3-13
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 个评论
Benjamin Thompson
Benjamin Thompson 2022-3-14
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.
Azime Beyza Ari
Azime Beyza Ari 2022-3-14
Thank you very very much for your time!! I will Try it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by