Okay I figured it out. It was a problem in my objective function.
Here is what happened: I have an aerodynamic solver included, this produced a numerical instability. At some point there is a calculation to approximate the maximum lift coefficient. This amplified the numerical instability and made a small part in the lift distribution negative. I did not anticipate this eventuality, which made one of the constraints complex. This happened several iterations before the actual error. The complex number probably got stuck in the Hessian, which eventually made fmincon produce a complex input vector.
The solution to prevent this from happening is to made fmincon stop as soon as a constraint or objective value gets complex. This can be done be putting 'FunValCheck','on' in the optimset line. This still makes the optimizer stop, but at least it stops at a point where the source of the error is.
This problem is now solved. Another one and a half day wasted. Should I now accept my own answer, that is a bit strange right.
2 Comments
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/11992-fmincon-creates-complex-input-vector#comment_26491
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/11992-fmincon-creates-complex-input-vector#comment_26491
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/11992-fmincon-creates-complex-input-vector#comment_26495
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/11992-fmincon-creates-complex-input-vector#comment_26495
Sign in to comment.