Skip to content

Commit 7a080b3

Browse files
1 parent d4ad15d commit 7a080b3

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

doxygen_cxx/classdrake_1_1solvers_1_1_mathematical_program_result.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ <h2 class="memtitle"><span class="permalink"><a href="#a83ded6cdb6fee1487b660f06
618618
<p>For a linear inequality constraint lower &lt;= A*x &lt;= upper where lower and upper ∈ ℝⁿ, dual_solution also has n rows. dual_solution(i) is the value of the dual variable for constraint lower(i) &lt;= A(i,:)*x &lt;= upper(i). If neither side of the constraint is active, then dual_solution(i) is 0. If the left hand-side lower(i) &lt;= A(i, :)*x is active (meaning lower(i) = A(i, :)*x at the solution), then dual_solution(i) is non-negative (because the objective is to minimize a cost, increasing the lower bound means the constraint set is tighter, hence the optimal solution cannot decrease. Thus the shadow price is non-negative). If the right hand-side A(i, :)*x&lt;=upper(i) is active (meaning A(i,:)*x=upper(i) at the solution), then dual_solution(i) is non-positive.</p>
619619
<p>For a bounding box constraint lower &lt;= x &lt;= upper, the interpretation of the dual solution is the same as the linear inequality constraint.</p>
620620
<p>For a Lorentz cone or rotated Lorentz cone constraint that Ax + b is in the cone, depending on the solver, the dual solution has different meanings:</p><ol type="1">
621-
<li>If the solver is Gurobi, then the user can only obtain the dual solution by explicitly setting the options for computing dual solution. <div class="fragment"><div class="line"> <span class="keyword">auto</span> constraint = prog.AddLorentzConeConstraint(...);</div><div class="line"> GurobiSolver solver;</div><div class="line"> <span class="comment">// Explicitly tell the solver to compute the dual solution for Lorentz</span></div><div class="line"> <span class="comment">// cone or rotated Lorentz cone constraint, check</span></div><div class="line"> <span class="comment">//</span></div><div class="line">https:<span class="comment">//docs.gurobi.com/projects/optimizer/en/12.0/reference/parameters.html#qcpdual</span></div><div class="line"> <span class="comment">// for more information.</span></div><div class="line"> SolverOptions options;</div><div class="line"> options.SetOption(<a class="code" href="classdrake_1_1solvers_1_1_gurobi_solver.html#a4dc451b7db72a168d9f0da1746011b45">GurobiSolver::id</a>(), <span class="stringliteral">&quot;QCPDual&quot;</span>, 1);</div><div class="line"> <a class="code" href="classdrake_1_1solvers_1_1_mathematical_program_result.html#a4fd3b5095ed206da42f1451c5dd426c5">MathematicalProgramResult</a> result = solver.Solve(prog, {}, options);</div><div class="line"> Eigen::VectorXd dual_solution = result.GetDualSolution(constraint);</div></div><!-- fragment --> The dual solution has size 1, dual_solution(0) is the shadow price for the constraint z₁² + ... +zₙ² ≤ z₀² for Lorentz cone constraint, and the shadow price for the constraint z₂² + ... +zₙ² ≤ z₀z₁ for rotated Lorentz cone constraint, where z is the slack variable representing z = A*x+b and z in the Lorentz cone/rotated Lorentz cone.</li>
621+
<li>If the solver is Gurobi, then the user can only obtain the dual solution by explicitly setting the options for computing dual solution. <div class="fragment"><div class="line"><span class="keyword">auto</span> constraint = prog.AddLorentzConeConstraint(...);</div><div class="line">GurobiSolver solver;</div><div class="line"><span class="comment">// Explicitly tell the solver to compute the dual solution for Lorentz</span></div><div class="line"><span class="comment">// cone or rotated Lorentz cone constraint, check</span></div><div class="line"><span class="comment">// https://docs.gurobi.com/projects/optimizer/en/12.0/reference/parameters.html#qcpdual</span></div><div class="line"><span class="comment">// for more information.</span></div><div class="line">SolverOptions options;</div><div class="line">options.SetOption(<a class="code" href="classdrake_1_1solvers_1_1_gurobi_solver.html#a4dc451b7db72a168d9f0da1746011b45">GurobiSolver::id</a>(), <span class="stringliteral">&quot;QCPDual&quot;</span>, 1);</div><div class="line"><a class="code" href="classdrake_1_1solvers_1_1_mathematical_program_result.html#a4fd3b5095ed206da42f1451c5dd426c5">MathematicalProgramResult</a> result = solver.Solve(prog, {}, options);</div><div class="line">Eigen::VectorXd dual_solution = result.GetDualSolution(constraint);</div></div><!-- fragment --> The dual solution has size 1, dual_solution(0) is the shadow price for the constraint z₁² + ... +zₙ² ≤ z₀² for Lorentz cone constraint, and the shadow price for the constraint z₂² + ... +zₙ² ≤ z₀z₁ for rotated Lorentz cone constraint, where z is the slack variable representing z = A*x+b and z in the Lorentz cone/rotated Lorentz cone.</li>
622622
<li>For nonlinear solvers like IPOPT, the dual solution for Lorentz cone constraint (with EvalType::kConvex) is the shadow price for z₀ - sqrt(z₁² + ... +zₙ²) ≥ 0, where z = Ax+b.</li>
623623
<li>For other convex conic solver such as SCS, MOSEK<a href="/tm.html"></a>, CSDP, etc, the dual solution to the (rotated) Lorentz cone constraint doesn't have the "shadow price" interpretation, but should lie in the dual cone, and satisfy the KKT condition. For more information, refer to <a href="https://docs.mosek.com/11.0/capi/prob-def-conic.html#duality-for-conic-optimization">https://docs.mosek.com/11.0/capi/prob-def-conic.html#duality-for-conic-optimization</a> as an explanation.</li>
624624
</ol>

pydrake/pydrake.solvers.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6170,8 +6170,7 @@
61706170
<span class="w"> </span><span class="n">GurobiSolver</span><span class="w"> </span><span class="n">solver</span><span class="p">;</span>
61716171
<span class="w"> </span><span class="c1">// Explicitly tell the solver to compute the dual solution for Lorentz</span>
61726172
<span class="w"> </span><span class="c1">// cone or rotated Lorentz cone constraint, check</span>
6173-
<span class="w"> </span><span class="c1">//</span>
6174-
<span class="nl">https</span><span class="p">:</span><span class="c1">//docs.gurobi.com/projects/optimizer/en/12.0/reference/parameters.html#qcpdual</span>
6173+
<span class="w"> </span><span class="c1">// https://docs.gurobi.com/projects/optimizer/en/12.0/reference/parameters.html#qcpdual</span>
61756174
<span class="w"> </span><span class="c1">// for more information.</span>
61766175
<span class="w"> </span><span class="n">SolverOptions</span><span class="w"> </span><span class="n">options</span><span class="p">;</span>
61776176
<span class="w"> </span><span class="n">options</span><span class="p">.</span><span class="n">SetOption</span><span class="p">(</span><span class="n">GurobiSolver</span><span class="o">::</span><span class="n">id</span><span class="p">(),</span><span class="w"> </span><span class="s">&quot;QCPDual&quot;</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>

0 commit comments

Comments
 (0)