实现最小化方法 [英] Implementing minimization method

查看:142
本文介绍了实现最小化方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个变量的函数 X1,X2

F = 3 * X1 ^ 2 + 4 * X2 ^ 2 + 5 * X1 + 6 * 2 + 10

考虑 X 是一个行向量,使得 X = [X5,X6] ,其中 X5,X6 是矢量的分量。如果符号是混乱的,让我们考虑 X = [X1,X1] ,但 X1,X2 可以是任意组件。同样的道理适用于

Consider x is a row vector such that x = [x5,x6], where x5,x6 are components of the vector. If the notation is confusing, let us consider x = [x1,x1] but x1,x2 can be any arbitrary components. The same argument holds for y.

然后我想找到 A (X + AY)这样,这将最大限度地减少˚F A 是实常数, X 是矢量。这是上面解释

Then I want to find a from (x + ay) such that it will minimize the f. a is real constant, x and y are vectors. This is explained above.

如果这个没有意义,那么让我们考虑 X,Y 与2位置的一维数组。所以,X(1)中,x(2)中,y(1)中,y(2)是其分量。然后我想乘阵列通过一个象征性的变量 A

If this does not make sense, then let us consider x,y as a 1-dimensional arrays with 2 locations. So, x(1),x(2),y(1),y(2) be their components. Then I want to multiply array y by a symbolic variable a.

例如, X = [4,5] Y = [ - 2,3] 然后, (X + AY)=(4,5)+ A(-2,3)=(4-2A,5 + 3A) A 是象征性的变量,它是未知的在这里。

For example, x=[4,5], y=[-2,3] then, (x + ay) = (4,5) + a(-2,3) = (4-2a,5+3a). a is symbolic variable that is unknown here.

代入 F1 (要在 F的定义更加清晰,第一个参数 X1 = 4-2A ,第二个参数 X2 = 5 + 3A

Substituting in f1 (To be more clear, first argument in the definition of f x1 = 4-2a, second argument x2=5+3a)

F1 = 3 *(4-2A)^ 2 + 4 *(5 + 3A)^ 2 + 5 *(4-2A)+ 6 *(5 + 3A)+ 10 ............(公式1)

f1 = 3*(4-2a)^2 + 4*(5+3a)^2 + 5*(4-2a) + 6*(5+3a) + 10 ............(eq. 1)

然后函数 F1 中的一个变量变得未知, A ,可以使用1D最小化算法,如最小化黄金部分的搜索,给定的时间间隔 [x_lower,x_upper]

Then function f1 becomes unknown in one variable, a and can be minimized using 1D minimization algorithm, such as golden section search, given an interval [x_lower,x_upper].

我的问题是:

由于不同的 X


  • 如何评价(X + AY)并通过(或替代品吗?),它变成功能 F(EQ1)

  • 如何建立动态功能 F1 ,在均衡器。 1,将它传递给1D最小化算法?通过动态,我的意思是这里是函数 F1 X每次,Ÿ将改变

  • How to evaluate (x+ay) and pass (or substitute ?) it into function f (eq1)?
  • How to create 'dynamic' function f1, as in eq. 1, to pass it to 1D minimization algorithm? By dynamic, I mean here is function f1 will change every time for x,y.

我感兴趣的是这个问题(坚持一个语言尽可能多地和不使用语言的特定功能或面向对象特征的基本特征)在python的低层次的实现,MATLAB,C或任何其他语言,但同样在低电平。你可以建议的东西吗?

I am interested in a low-level implementation of this problem (sticking to the basic features of a language as much as possible and without using language specific features or object oriented features) in python, MATLAB, C or any other language, but again in 'low level.' Can you suggest something?

更新:我不想用符号处理从蟒蛇,MATLAB或任何其他语言

UPDATE: I don't want to use symbolics from python, MATLAB or from any other language.

推荐答案

我在改写你的问题在​​我自己的话,因为在目前形式的问题是混乱的:

I'm rephrasing your question in my own words, because the question in its current form is confusing:

你有一个函数 F(X1,X2)= 3 * X1 ^ 2 + 4 * X2 ^ 2 + 5 * X1 + 6 * 2 + 10 X1 X2 从总结 X A ,其中 X 给出向量和 A 是一个标量。你想获得从步骤f 替换这个关系到产生的功能。

You have a function f(x1,x2) = 3*x1^2 + 4*x2^2 + 5*x1 + 6*x2 + 10. x1 and x2 are the components of a 2D vector obtained from summing x with the product of a and y, where x and y are given vectors, and a is a scalar. You want to obtain the function that results from substituting this relation into f.

请注意,该符号是有点混乱,所以我会改用 X = Z +一个* Y ,其中z(更换您使用的X)和y给定的载体。

Note that the notation is a bit confusing, so I will use instead x = z+a*y, where z (replacing the x you used) and y are the given vectors.

让我们定义˚F作为在Matlab匿名函数(你可以很容易地使用功能的文件以及):

Let's define f as an anonymous function in Matlab (you could easily use a function file as well):

f = @(x) 3*x(1)^2 + 4*x(2)^2 + 5*x(1) + 6*x(2) + 10;

请注意,我在不同的写这比你做,即×(1) X(2)而不是 X1 X2 。这意味着,我使用的是矢量,而不是两个不相关的变量的组成部分。

Note that I'm writing this differently than you did, i.e. x(1) and x(2) instead of x1 and x2. This means that I am using components of a vector instead of two unrelated variables.

那么,让我们来写你的公式,涉及 A 作为函数,以及:

Then, let's write your equation involving a as a function as well:

g = @(a) z + a*y;

函数g(一)返回每一个vector A ,服从克(A)= Z + A * Y

现在,你可以做替代:

h = @(a) f(g(a))

^ h 是所需的函数,它接受一个作为输入并返回值 A 在获得的载体应用从 Z +一个* Y

h is the desired function that takes a as input and returns the value of a applied at the vector obtained from z+a*y.

这篇关于实现最小化方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆