MATLAB nonlinear objective function - matlab

I have an OR model, with linear constraints and a nonlinear objective function. Is it impossible to solve it with "linprog"? If so, are there any methods to linearize objective functions, fore example by adding some constraints to the model?
Thanks for your help.

`linprog' solves linear programming problems, and the objective function should be linear. The nonlinear objective functions can be linearized with mathematical linearization method.
Linearization is a linear approximation of a nonlinear system that is valid in a small region around the operating point.
For example you can use Function approximation for linearization. Taylor approximation is one of the methods. The linearization of a function is the first order term of its Taylor expansion around the point of interest. There exist other methods as well.
Matlab has a document for basic methods and functions of linearization that you may check.
If you support the question with code, people at SO can help more with the problem.

If you have Matlab at your disposition, and can use any of the optimization toolbox's functions, you should look at fmincon, which minimizes nonlinear objective functions under linear and nonlinear constraints.

Related

MATLAB collect terms with common denominator

I'm writing some MATLAB code that gives a symbolic equation. The equation has a number of fractional terms where the denominators are different functions. I would like to group the terms with the same denominator. To give an example of what I'm trying to achieve assume the following equation:
[1]
Where the x_i's are different functions in my case. Is there a function in MATLAB that can achieve this? or if you could write an algorithm that would be extremely helpful.
[1]: https://i.stack.imgur.com/TtYGc.png
If you are using Matlab's Symbolic Math Toolbox™ (meaning using syms to create symbolic variables and combining those into functions etc...) then the symplify function should do the trick. For more read: Preforming symbolic computations

How does MATLAB's fit() function differentiate arbitrary MATLAB expressions for Levenberg-Marquardt to be applicable?

As far as I understand the LM algorithm, it is an improvement over the Newton's method, so very roughly speaking, an algorithm which tries to build a path in the parameter space, leading to the point where the error function is minimal, which follows the direction of the biggest gradient of error function (differentiated with respect to the parameters).
I have written a Newton's method optimizer for a neural network once, as an exercise, and the critical part of the algorithm was that we could apply the chain rule (error backpropagation) to compute the gradient. And it was me who used the chain rule to the write out a formula for the gradients. (Essentially by symbolic differentiating on paper once and coding the resulting formula.)
In MATLAB (Curve Fitting Toolbox), there is a standard fit() function, which claims to use Levenberg-Marquardt's method to fit basically any parametric MATLAB expression as well as a set of prepared models.
Well, I suspect that the prepared models could be pre-differentiated by Mathworks' engineers to generate the code for the gradients. But what about the 'arbitrary' fits?
Is MATLAB trying to do symbolic differentiation implicitly? I highly doubt that anyone can write rules for differentiation of all the complex MATLAB constructions, i.e. classes and enumerations.
Or, maybe MATLAB is just differentiating the function by evaluating it in ξ and ξ+Δξ and dividing by Δξ? But that would require finding the best shift and require n+1 function evaluations, where n is the number of parameters optimized.
And in any case, even this strategy would fail if the function is not differentiable, which I suspect to be the case for almost any general MATLAB expression.
Could anyone give a plausible hypothesis of what is actually happening inside?
(Well, knowing what actually happens inside would be even better, but even an informal insight would be great.)

Which C++ library is perfect in solving non-linear set of equations with complex roots?

I am developing a small kinetic Monte Carlo code to study atomic evolutions in a material and need to solve several linear and non-linear equations with a high accuracy. My main issue is in finding complex roots of a non-linear equation.
Which C++ library is perfect for solving a non-linear set of equations with complex roots? I am already using Eigen and Ceres in my codes, but it seems that they only can find "real" roots and not "complex" ones.
All recommendations and ideas are appreciated in advance.
Update-1:
For example, Eigen provides a nonlinear optimization module,
https://eigen.tuxfamily.org/dox/unsupported/group__NonLinearOptimization__Module.html
which uses (1)Levenberg Marquardt algorithm and (2)Powell hybrid "dogleg" method to find roots and extremums of a nonlinear set of equations. As far as I know, these methods can't find complex roots if any.

What kind of numerical method does 'pdepe' (MATLAB function's) use?

I'm using the MATLAB's function 'pdepe' to solve a problem with some partial differential equations, a parabolic one.
I need to know the kind of numerical method that function uses, 'cause I have to notify this in a report.
The description of the function in MathWorks is "Solve initial-boundary value problems for systems of parabolic and elliptic PDEs in one space variable and time". Is it a finite difference method?
Thanks for helping me.
Taken from the Matlab 2016b documentation for pdepe:
The time integration is done with ode15s. pdepe exploits the
capabilities of ode15s for solving the differential-algebraic
equations that arise when Equation 1-3 contains elliptic equations,
and for handling Jacobians with a specified sparsity pattern.
Also, from the ode15s documentation:
ode15s is a variable-step, variable-order (VSVO) solver based on the
numerical differentiation formulas (NDFs) of orders 1 to 5.
Optionally, it can use the backward differentiation formulas (BDFs,
also known as Gear's method) that are usually less efficient
As indicated by Alessandro Trigilio, ode15s is used to advance the solution forward in time. Exactly what the function is advancing in time is a semi-discrete, second-order Galerkin formulation for non-singular problems or a semi-discrete, second-order Petrov-Galerkin formulation for singular problems (polar or spherical meshes that include the origin). As such, the spatial discretization is finite element in nature.

Optimization of multivariable function In Matlab

I have a function fun(x,y,z), such that say, x=1:10, y=50:60, z=100:105. Which optimization method (and how) I can use to get the minimum of this function, for example, where (x,y,z)=(3,52,101). I am working in Matlab.
Thank you for any help
Algorithms
There are many many algorithms out there that you can use for direct search optimization such as Nelder-Mead, Particle Swarm, Genetic Algorithm, etc.
I believe Nelder-Mead is a simplex optimization method which is used by fminsearch function in MATLAB.
Also, there is Genetic Algorithm which comes with MATLAB Global Optimization toolbox. You may want to give that a try as well.
Particle Swarm Optimization (PSO) is another direct search method that you can use. However, there is no official toolbox for Particle Swarm method built by Mathworks. The good news is there is quite a few PSO toolbox developed by other people. I personally have used this one and am quite happy with the performance. Its syntax is similar to Genetic Algorithm functions that come with Global Optimization Toolbox.
Discrete Optimization
Regarding your question that you are looking for a set of integer values namely x,y, and z corresponding to the minimum objective function value, I would add a part at the beginning of the objective function that rounds the variables to the closest integers and then feeds them to your main function fun(x,y,z). This way you would discretize your function space.
I hope my answer helps.