필터 지우기
필터 지우기

Problem with Linear inequality constraints

조회 수: 4 (최근 30일)
Azime Beyza Ari
Azime Beyza Ari 2022년 3월 30일
편집: Torsten 2022년 3월 30일
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
Matt J
Matt J 2022년 3월 30일
편집: Matt J 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
Azime Beyza Ari 2022년 3월 30일
Yes, Thank you!

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 3월 30일
편집: Matt J 2022년 3월 30일
sum(over j)(xij)<=1 for each i
This constraint can be written,
x=rand(36);
[m,n]=size(x);
A=kron(ones(1,n),speye(m)); b=ones(m,1);
You can check the equivalence as follows:
difference=sum(x,2) - A*x(:)
difference = 36×1
0 0 0 0 0 0 0 0 0 0
  댓글 수: 17
Matt J
Matt J 2022년 3월 30일
편집: Matt J 2022년 3월 30일
It would not be easier with a different solver since in all MATLAB solvers for optimization, you would have to set up A and b.
No, if you were to use intlinprog, but through the problem-based workflow, there would be no need to explicitly create A and b. This would be done for you internally by optimproblem().
So it all ends with how i set up A, b, and (of course) objfunc Which all three i am currently failing to do properly.
So far, nothing has been found to be incorrect in your objective function.
Torsten
Torsten 2022년 3월 30일
편집: Torsten 2022년 3월 30일
It would not be easier with a different solver since in all MATLAB solvers for optimization, you would have to set up A and b.
I should have added: if you use the solver-based approach.
The problem-based approach looks simple, but I have the feeling that one looses too much control over the problem. Checking how settings are internally translated (kind of debugging possibility) is impossible (at least as far as I can see). But as so many things: it's a matter of taste.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by