You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

带不等式约束的多值函数优化:偏导非零疑问及解析求解

Great question! Let's break this down step by step to clear up your confusion and walk through the analytical solution.

1. Why the partial derivative with respect to x isn't zero at the maximum point

The key here is recognizing that we're dealing with a boundary point, not an interior local maximum. For unconstrained optimization, we require the gradient to be zero at extrema—but when variables are pinned to inequality constraint boundaries, this rule no longer applies.

Your optimal point $(1, 2.4, 5.6, 7)$ has $x=1$, which hits the hard lower bound $x\geq1$. For such boundary points, we use the KKT conditions (the extension of Lagrange multipliers to inequality constraints) instead of standard gradient zero conditions. Here's what that means for $x$:

  • The constraint $x\geq1$ can be rewritten as $1-x\leq0$.
  • The KKT condition for this constraint states that $\lambda_1(1-x)=0$ (complementary slackness) and $\lambda_1\geq0$, where $\lambda_1$ is the Lagrange multiplier for this constraint.
  • Since $x=1$, $\lambda_1$ can be positive. The first-order condition becomes:
    $$\frac{\partial f}{\partial x} = \lambda_2 - \lambda_1$$
    Since $y>x$, the constraint $y\geq x$ is not tight, so $\lambda_2=0$. This leaves $\frac{\partial f}{\partial x}=-\lambda_1$. Your calculated $\frac{\partial f}{\partial x}\approx-0.73$ (you likely took the absolute value) gives $\lambda_1\approx0.73\geq0$, which satisfies the KKT conditions.

In short: the partial derivative doesn't need to be zero because $x$ is stuck at its minimum allowed value—moving $x$ higher would only decrease $f$, so the gradient points in the direction of decreasing $x$, which is blocked by the constraint.

2. Analytical Solution Using KKT Conditions

Lagrange multipliers work for equality constraints, but we need the KKT conditions to handle inequality constraints. Let's formalize this:

Step 1: Define the problem and constraints

We want to maximize:
$$f=\ln(1+(y-x))+\ln(1+(z-x))+\ln(1+(w-x))+\ln(1+(z-y))+\ln(1+(w-y))+\ln(1+(w-z))$$
Subject to:

  • $g_1=1-x\leq0$ (i.e., $x\geq1$)
  • $g_2=x-y\leq0$ (i.e., $y\geq x$)
  • $g_3=y-z\leq0$ (i.e., $z\geq y$)
  • $g_4=z-w\leq0$ (i.e., $w\geq z$)
  • $g_5=w-7\leq0$ (i.e., $w\leq7$)

Step 2: Construct the KKT Lagrangian

For maximization, the Lagrangian is:
$$L = f - \lambda_1(1-x) - \lambda_2(x-y) - \lambda_3(y-z) - \lambda_4(z-w) - \lambda_5(w-7)$$
Where $\lambda_i\geq0$ for all $i$, and complementary slackness holds: $\lambda_i g_i=0$ (if a constraint isn't tight, its multiplier is zero).

Step 3: Eliminate impossible cases

First, check if an interior maximum (all constraints non-tight) is possible:

  • $\frac{\partial f}{\partial x} = -\left(\frac{1}{1+y-x}+\frac{1}{1+z-x}+\frac{1}{1+w-x}\right)$ is always negative (sum of positive terms multiplied by -1). It can never be zero, so an interior maximum doesn't exist.

This tells us at least one constraint must be tight. We can test combinations:

  • If $w<7$, $\frac{\partial f}{\partial w}$ is a sum of positive terms (can't be zero), so $w$ must be at its upper bound $w=7$.
  • If $x>1$, $\frac{\partial f}{\partial x}$ is negative, meaning increasing $x$ decreases $f$—so the optimal $x$ is its lower bound $x=1$.

Step 4: Solve for y and z

Now we know $x=1$ and $w=7$, with $y>x$ and $z>y$ (so $\lambda_2=\lambda_3=\lambda_4=0$). The first-order conditions reduce to:

  1. $\frac{\partial f}{\partial y}=0$: $\frac{1}{y} - \frac{1}{1+z-y} - \frac{1}{8-y}=0$
  2. $\frac{\partial f}{\partial z}=0$: $\frac{1}{z} + \frac{1}{1+z-y} - \frac{1}{8-z}=0$

From the second equation, rearrange to solve for $1+z-y$:
$$\frac{1}{1+z-y} = \frac{1}{8-z} - \frac{1}{z} = \frac{2z-8}{z(8-z)}$$
$$1+z-y = \frac{z(8-z)}{2(z-4)}$$

Substitute this into the first equation, simplify, and solve for $z$. You'll find $z=\frac{28}{5}=5.6$, then substitute back to get $y=\frac{12}{5}=2.4$. This gives the point $(1, 2.4, 5.6,7)$ from WolframAlpha.

Step 5: Verify optimality

This point satisfies all KKT conditions:

  • $\lambda_1=-\frac{\partial f}{\partial x}\approx0.73\geq0$ (complementary slackness for $x=1$)
  • $\lambda_5=\frac{\partial f}{\partial w}\approx0.73\geq0$ (complementary slackness for $w=7$)
  • All other multipliers are zero (non-tight constraints)
  • Partial derivatives for $y$ and $z$ are zero (interior to their constraints)

3. Key Takeaways

  • Boundary extrema don't require gradient zero: When a variable hits an inequality constraint, the gradient only needs to align with the constraint's direction (via KKT multipliers), not vanish.
  • KKT conditions replace Lagrange multipliers for inequalities: They add complementary slackness and non-negative multipliers to handle tight/loose constraints.
  • Eliminate impossible cases first: We quickly ruled out interior maxima by checking the sign of $\frac{\partial f}{\partial x}$, narrowing down to tight constraints for $x$ and $w$.

内容的提问来源于stack exchange,提问作者Paul R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:38:09