Minimizing quadratic energies with constant constraints

There are a many different ways to minimize a quadratic energy with constant constraints. I wrote out the exact steps for three such ways:

  1. Separate the energy into knowns and unknowns, then solve for the
    unknowns by setting gradient with respect to those unknowns to zero.
  2. Add additional term to energy that punishes not satisfying the known
    values of your constant constraints in the least squares sense, the
    solve for all variables by setting gradient with respect to all
    variables to zero.
  3. Add additional variables called lagrange multipliers to energy so
    that the problem is no longer to find a minimum but a stationary
    point in the new energy. Such a stationary point guarantees that our
    constraints are met. Find the stationary point by the usual method
    of setting the gradient to zero, this time the gradient is with
    respect to all original variables and these new variables.

The pretty print type-up with MATLAB pseudocode.
A plain text, unicode version:

Quadratic energy
E=ZTQZ+ZTL+C

We want to fix some of the values of Z, we can rearrange the Z’s that are still
free and the ones we want to fix so that Z=[XY] , where X are the free values
and Y are the fixed values;

Split energy into knowns and unknowns
Z=[XY]
or
Z(unknown) = X and Z(known) = Y

E===[XT YT]Q[XY]+[XT YT]L+C[XT 0]Q[XY]+[0 YT]Q[XY]+[XT 0]L+[0 YT]L+C[XT 0]Q[X0]+[XT 0]Q[0Y]+[0 YT]Q[X0]+[0 YT]Q[0Y]+[XT 0]L+[0 YT]L+C

E=[XT 0][Q(unknown,unknown)000][X0]+[XT 0][00Q(unknown,known)0][0Y]+[0 YT][0Q(known,unknown)00][X0]+[0 YT][000Q(known,known)][0Y]+[XT 0]L+[0 YT]L+C

E===XTQ(unknown,unknown)X+XTQ(unknown,known)Y+YTQ(known,unknown)X+YTQ(known,known)Y+XTL(unknown)+YTL(known)+CXTQ(unknown,unknown)X+XTQ(unknown,known)Y+(YTQ(known,unknown)X)T+YTQ(known,known)Y+XTL(unknown)+YTL(known)+Cthe transpose of a scaler is the scaler itselfXTQ(unknown,unknown)X+XTQ(unknown,known)Y+XTQ(known,unknown)TY+YTQ(known,known)Y+XTL(unknown)+YTL(known)+C

E=XTNQX+XTNL+NC
where
NQ=Q(unknown,unknown)
NL=Q(unknown,known)Y+Q(known,unknown)TY+L(unknown)
NC=YTQ(known,known)Y+YTL(known)+C

EX=2NQX+NL

Solve for X with:
X=(2NQ)1NL

Enforce fixed values via soft contraints with high weights

E=ZTQZ+ZTL+C
Add new energy term punishing being far from fixed variables
NE=ZTQZ+ZTL+C+w(Z(known)Y)TI(Z(known)Y)
where w is a large number, e.g. 10000
NE=ZTQZ+ZTL+C+w(ZT[0 YT])[000I(known,known)](Z[0Y])
where W is a diagonal matrix with Wii=0 if iunknown and Wii=w if iknown
NE=ZTQZ+ZTL+C+(ZT[0 YT])W(Z[0Y])
NE=ZTQZ+ZTL+C+ZTWZ2ZTW[0Y]+[0 YT]W[0Y]
NE=ZTNQZ+ZTNL+NC
NQ=Q+W
NL=L2W[0Y]
NC=C+[0 YT]W[0Y]

Differentiate with respect to Z
EZ=2NQZ+NL

Solve for Z with:
Z=0.5NQ1NL
or re-expanded
Z=0.5(Q+W)1(L2W[0Y])

Discard known parts of Z to find X
X=Z(unknown)
But be careful to look at Z(known) - Y to be sure your fixed values are being
met, if not then w is too low. If the X values look like garbage then perhaps
you’re getting numerical error because w is too high.

Lagrange multipliers

We want to minimize
E=ZTQZ+ZTL+C
subject to the constant constraints:
Z(known)=Y
Find stationary point of new energy:
NE=E+λi(ZiYi) ,i∈known
NE=E+[ZT λT]QC[Zλ][ZT λT][02Y]
(notice the 2 because λZ shows up twice in the quadratic part)
where QC=00000I(known,known)0I(known,known)0
NE=[ZT λT]NQ[Zλ]+[ZT λT]NL+C
NQ=[Q000]+QC=Q012I(known,known)012I(known,known)0
NL=[L0]+[0Y]
Differentiate with respect to all variables, including lagrange multipliers
E[Zλ]=2NQ[Zλ]+NL
Solve with
[Zλ]=0.5NQ1NL

Discard fixed values and langrange multipliers.
X = Z(known)
The value of λi is the “force” of the constraint or how hard we had to pull the
energery minimum to meet the constraints. See
http://www.slimy.com/~steuard/teaching/tutorials/Lagrange.html#Meaning

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值