symbolic maths and optimization
Show older comments
i am trying to maximize a nonlinear objective function which is based on the entropy type..During my formulation of the problem i use some matrices to extract information and by this i create the tables Aeq and beq Aeq=84*126 (so 84 linear equations and 126 X variables) for the representation of my linear constaints.My problem has also some nonlinear equality constraints which i create in a new script (as i should) using symbolic maths..Specifically i create the nonlinear symbolic equations
xR = sym('xR', [1 20]); where xR(1)=X85*X105, xR(2)=X86*X106, xR(3)=X87*X107, xR(4)=X88*X108....xR(20)=X104*X124
avg_xR = sym('avg_xR', [1 2]); where avg_xR(1)=( X85*X105 + X87*X107 + X89*X109 + X91*X111 + X93*X113 + X95*X115 + X97*X117 + X99*X119 + X101*X121 + X103*X123 ) / 10 and avg_xR(2)=( X86*X106 + X88*X108 + X90*X110 + X92*X112 + X94*X114 + X96*X116 + X98*X118 + X100*X120 + X102*X122 + X104*X124 ) / 10
xS = sym('xS%d%d',[2 2]); where xS(rc,rk) = SUM(10, (xR(t,rc)-avg_xR(rc))*(xR(t,rk)-avg_xR(rk))) / (10-1); where for example xs(1,1)=(avg_xR1 - X85*X105)^2 + (avg_xR1 - X87*X107)^2 + (avg_xR1 - X89*X109)^2 + (avg_xR1 - X91*X111)^2 + (avg_xR1 - X93*X113)^2 + (avg_xR1 - X95*X115)^2 + (avg_xR1 - X97*X117)^2 + (avg_xR1 - X99*X119)^2 + (avg_xR1 - X101*X121)^2 + (avg_xR1 - X103*X123)^2
Now we only have equations of X's here but no constraint...well the nonlinear equality constraint will actually be something like xs(1,1) = 14.3 xs(1,2) = 8.7 etc..So we can now have the form ceq(x) = 0.
I am using the fmincon solver to run my optimization because thats the one tha fits to my problem best and then i might run it with the genetic algorithms solver..my question is...How can i use these symbolic nonlinear constraintsin my optimization??
2 Comments
John D'Errico
on 4 Feb 2019
There is absolutely no need for this to be a symbolic problem at all. NONE. Period. Read the help about fmincon. See how to write a function.
Using symbolic variables gains you nothing at all, except for massively slowing the code down.
Just because you don't know the value of avariable in advance does not mean it needs to be symbolic. That is what an optimization tool (fmincon) does for you.
Takis Tsoukalas
on 5 Feb 2019
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display 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!