I updated your optimization function and the solution c is as follow Another issue A = int(f,)-int(g,) = 55/6 - c^5/5 instead ofĪ = 2*(int(f,)-int(g,)) = 55/3 - (2*c^5)/5įactor 2 is used whether for even whether for odd function (like cosine or since).Įven for those kind of function the integration interval is reduced by half Your problem is more related to calculus than matlab tool constraints like function cconsQ6(x) cx < 0 x > 0 are just ignored by fmincon, because they are not logical Technically you need to know the optimum c before solving this optimization problem - Another issue A int(f,0,5)-int(g,0,c) 55/6 - c5/5 instead of A 2(int(f.Technically you need to know the optimum c before solving Your problem is more related to calculus than matlab toolĬ= are just ignored by fmincon, because they are not logical Does anyone know why this happens and why MATLAB does not respect the constraints when I put them up for the whole range ? For example, suppose that you have the following inequalities as constraints: x 1 2 9 + x 2 2 4 1, x 2 x 1 2 1. Return an empty entry for a nonexistent constraint. However, it is behaving in a way that I cannot explain. But when I delete the unneccessary constraints in the range ]2 5] function =cons_Q6(x) 1.6K 215K views 5 years ago Computational Tools for Engineers This step-by-step tutorial demonstrates fmincon solver on a nonlinear optimization problem with one equality and one inequality. Nonlinear constraint functions must return both c and ceq, the inequality and equality constraint functions, even if they do not both exist. I am trying to perform nonlinear optimization using fmincon. Now, when I solve it like this I get a solution that doesn't fit all the constraints. Function returning the current values of nonlinear inequality constraints (constrained to < 0 ) in the first output and the. = constraints file looks like this (I inserted a lot of values for x with an increment of 0.1): function =cons_Q6(x)Īs you can see, I've set the bounds for the unknown variable so that x(1)= and I have set the constraints in the range although I would only need them in the range of because of the bounds for x(1). Minimize A=2*(int(f,)-int(g,))=55/3 - (2*c^5)/5Īlso I have the constraint that f(x) must always be 1 unit above the functions g(x) and h.įrom the graph I know that the variable c must be between 0 and 2 (just a range for the fmincon function). The function that computes the nonlinear inequality constraints c(x)0 c ( x ) 0 and the nonlinear equality constraints ceq(x)0. I want to minimize the Area between the function f(x) and the two connected functions g(x) and h, in the interval I want to use MATLABs fmincon function to solve a non-linear problem of which I know that it can be solved in a different way very easily but I want to use fmincon (you might not need the following detailed information about the problem but I provided them in case you need):įunction f(x) is a quadratic function with its vertex at point (5|1).įunction g(x) is a polynom of order 4 with its vertex at Point (c|0).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |