I need to solve a nonlinear problem in n symbolic variables. The objective function to maximize is just a sum/difference of products of a variable with itself or with another one, so it is basically a quadratic equation.
The problem is that I need to impose a symbolic limit on the sum of these variables, as well as limit the values of these variables to be between 0 and 1 inclusive.
So I need an upper bound expressed as a function of the (symbolic) sum and not as a number. Can Matlab solve such kind of problems? If yes, how?
EDIT: Basically I need to perform the optimization of a symbolic problem with a quadratic objective function and linear constraints.
Related
I am struggling to solve an optimization problem, numerically, of the following (generic) form.
minimize F(x)
such that:
___(1): 0 < x < 1
___(2): M(x) >= 0.
where M(x) is a matrix whose elements are quadratic functions of x. The last constraint means that M(x) must be a positive semidefinite matrix. Furthermore F(x) is a callable function. For the more curious, here is a similar minimum-working-example.
I have tried a few options, but to no success.
PICOS, CVXPY and CVX -- In the first two cases, I cannot find a way of encoding a minimax problem such as mine. In the third one which is implemented in MATLAB, the matrices involved in a semidefinite constraint must be affine. So my problem falls outside this criteria.
fmincon -- How can we encode a matrix positivity constraint? One way is to compute the eigenvalues of the matrix M(x) analytically, and constraint each one to be positive. But the analytic expression for the eigenvalues can be horrendous.
MOSEK -- The objective function must be a expressible in a standard form. I cannot find an example of a user-defined objective function.
scipy.optimize -- Along with the objective functions and the constraints, it is necessary to provide the derivative of these functions as well. Particularly in my case, that is fine for the objective function. But, if I were to express the matrix positivity constraint (as well as it's derivative) with an analytic expression of the eigenvalues, that can be very tedious.
My apologies for not providing a MWE to illustrate my attempts with each of the above packages/softwares.
Can anyone please suggest a package/software which could be useful to me in solving my optimization problem?
Have a look at a nonlinear optimization package with box constraints, where different type of constraints may be coded via penalty or barrier techniques.
Look at the following URL
merlin.cs.uoi.gr
My functional model consists of a nonlinear conditional equation of the form
a^x + b^x - 1 = 0
a and b are known. Therefore, I can solve this easily using Gauss-Newton iterations or MATLAB's in-built fsolve function. But: What if I have multiple versions of (a,b) tuples fitting the same model defined by x?
I'd like to solve the resulting overdetermined system by MATLAB's lsqnonlin function, but it of course aims only at minimizing the sum of residuals, whereas I want to minimize the sum of residuals AND the conditional equations be fullfilled. What's the proper proceeding here?
How do I solve a quadratic Maximization problem in MATLAB? It seems MATLAB only supports minimization problems, so is there a mathematical concept I can use?
simply multiply by (-1) before and after using the minimization function
Using quadprog function in MATLAB.
This function solves Quadratic Programming problems in MATLAB.
Of course if you want the maxima instead of the minima, you can multiply the cost function by -1.
Good Luck.
The above answer #Drazick seems not right.
quadprog() in matlab requires H to be positive definite. If we simply multiply (-1), -H is a negative definite matrix, which violates the requirement.
Another optimization function called fmincon( ) may help.
I'm not too familiar with MATLAB or computational mathematics so I was wondering how I might solve an equation involving the sum of squares, where each term involves two vectors- one known and one unknown. This formula is supposed to represent the error and I need to minimize the error. I think I'm supposed to use least squares but I don't know too much about it and I'm wondering what function is best for doing that and what arguments would represent my equation. My teacher also mentioned something about taking derivatives and he formed a matrix using derivatives which confused me even more- am I required to take derivatives?
The problem that you must be trying to solve is
Min u'u = min \sum_i u_i^2, u=y-Xbeta, where u is the error, y is the vector of dependent variables you are trying to explain, X is a matrix of independent variables and beta is the vector you want to estimate.
Since sum u_i^2 is diferentiable (and convex), you can evaluate the minimal of this expression calculating its derivative and making it equal to zero.
If you do that, you find that beta=inv(X'X)X'y. This maybe calculated using the matlab function regress http://www.mathworks.com/help/stats/regress.html or writing this formula in Matlab. However, you should be careful how to evaluate the inverse (X'X) see Most efficient matrix inversion in MATLAB
I want to solve a system of non-linear equations in matlab such that the solutions are positive. Can I specify in matlab that I want positive solutions for unknown variables? How?
Yes, you can define the variables with syms like:
syms x y positive
and those variables are constained to be positive. See fsolve for how to find the solution after you have define the constraints on variables.