Problem with Linear inequality constraints
이전 댓글 표시
Hello everyone,
I am trying to do an optimization using genetic algorithm solver. I have linear inequality constraints and i am having trouble properly defining them.
First of all, although my objective function gives not enough input argument error, it works(colud not solve this error i have tried everything). Next step is defining the constraints. I have several constraints, to be more exact including the domain constraints(2) i have 6.
My problem has variables and paremeters with (mostly) dimensions 36x36. I have choosed one constraint to test before proceeding with the rest of the constraints. i have choosed this one ;
sum(over j)(xij)<=1 for each i
what i did was;
i have created A matrix and b vector since this is an inequality constraint. In the A matrix i wrote 1's and 0's. in the b matrix i wrote 1 since that is what i desire.
But it does not assign any values to my variables (xij), and best solution returns as 0.
I will attch the file, if you can have a look i would be appreacited.
Thank you in advance.
Beyza.
댓글 수: 10
Torsten
2022년 3월 30일
What was your objective function ?
What were possibly other constraints on the x_ij (e.g. only 0 or 1, positive or something else)
Azime Beyza Ari
2022년 3월 30일
편집: Azime Beyza Ari
2022년 3월 30일
First of all, although my objective function gives not enough input argument error, it works(colud not solve this error i have tried everything)
Do you mean this?

If so, what is unclear? The error message is complaining that you are not providing input arguments and indeed, you are providing none. What are you trying to do in that line?
Azime Beyza Ari
2022년 3월 30일
편집: Azime Beyza Ari
2022년 3월 30일
Matt J
2022년 3월 30일
The line that is causing the error is the one I highlighted in blue. I did not tell you to put it there. You are invoking your objective function without passing in any xij. Did you mean to have,
objfun2(solution2)
Azime Beyza Ari
2022년 3월 30일
Matt J
2022년 3월 30일
Get rid of this line
% Clear variables
clearvars objfun2 options2
Azime Beyza Ari
2022년 3월 30일
What are you trying to do? Are you just trying to see the objective function value? If so, just write,
objectiveValue
I did not write that line. And can not delete it, it does not allow me.
Just for reference, you can convert the Live Task to editable code using the drop down menu in the upper right corner of the task

Azime Beyza Ari
2022년 3월 30일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

