the fmincon sets a wrong dimension for my decision variables and that gets me errors on dimension disagreement.
Show older comments
I have a nonlinear objective function with nonlinear constraints that I would like to minimize. I pass parameters and functions for the calculation of the objective function and constraints. So basically my fmincon looks like this:
[x,FVAL]=fmincon(@(x)myOF(x,PSR,PEBU,PWE,PLE,PAE,PHW,PHT,PMT,PST,PHR,PIVTT,PIVTQ,PIVTH,PIVTE,PIVTWE,PIVTLE,PIVTAE,PIVTHW,PCT,PICTE,PMSCp,POR,PER,PSEp,PICTWE,PICTLE,PICTAE,PICTHW,AHW,DHW,VHW,AWE,DWE,VWE,AAE,DAE,VAE,ALE,DLE,VLE,UP,I,J,K,T),x0,[],[],[],[],[],[],@(x)constraints(x,PSR,PEBU,PWE,PLE,PAE,PHW,PHT,PMT,PST,PIVTH,PIVTE,PIVTWE,PIVTLE,PIVTAE,PIVTHW,PCT,PICTE,PICTWE,PICTLE,PICTAE,PICTHW,IB,D,I,J,K,T),options);
'myOF' and 'constraints' are both functions of x and many parameters and the all the parameters are imported from excel. all the parameters are matrices of four dimensions.
I define my x0 to be a zero matrix with four dimensions but after I run the optimization I get error on dimension match because the x matrix is automatically set to be a 2 dimensional. when I run 'myOF' and 'constraints' manually I get no errors.. I am wondering how I can control the dimension of the final x matrix so that Matlab can continue the calculations without having problems with the non-matching dimensions.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!