Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on the comment from Robert Kern, I have removed my previous answer. Here are the constraints as continuous functions:</p> <pre><code>b1 = lambda x: x[4]-x[0] if x[4]&lt;1.2*x[0] else 1.4*x[0]-x[4] b2 = lambda x: x[5]-x[1] if x[5]&lt;1.2*x[1] else 1.4*x[1]-x[5] b3 = lambda x: x[2]-x[3] </code></pre> <p>Note: Python 2.5 or greater is required for this syntax.<sup>1</sup></p> <p>To get the constraint <code>a&lt;=e&lt;=1.4*a</code>, note that <code>1.2*a</code> is the halfway point between <code>a</code> and <code>1.4*a</code>.</p> <p>Below this point, that is, all <code>e&lt;1.2*a</code>, we use the continuous function <code>e-a</code>. Thus the overall constraint function is negative when <code>e&lt;a</code>, handling the lower out-of-bounds condition, zero on the lower boundary <code>e==a</code>, and then positive for <code>e&gt;a</code> up to the halfway point.</p> <p>Above the halfway point, that is, all <code>e&gt;1.2*a</code>, we use instead the continuous function <code>1.4*a-e</code>. This means the overall constraint function is is negative when <code>e&gt;1.4*a</code>, handling the upper out-of-bounds condition, zero on the upper boundary <code>e==1.4*a</code>, and then positive when <code>e&lt;1.4*a</code>, down to the halfway point.</p> <p>At the halfway point, where <code>e==1.2*a</code>, both functions have the same value. This means that the overall function is continuous.</p> <p>Reference: <a href="http://projects.scipy.org/scipy/attachment/ticket/565/slsqp.py" rel="nofollow noreferrer">documentation for <code>ieqcons</code></a>.</p> <p><sup><strong>1</strong> - Here is pre-Python 2.5 syntax: <code>b1 = lambda x: (1.4*x[0]-x[4], x[4]-x[0])[x[4]&lt;1.2*x[0]]</code></sup></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload