Skip to content

Commit

Permalink
Deploying to gh-pages from @ 49916b6 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Nov 27, 2024
1 parent 89e90e0 commit 96e2ead
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 62 deletions.
2 changes: 2 additions & 0 deletions _sources/examples/optimal_control_rocket.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ After solving the problem, we can plot the results.

```{code-cell}
model.optimize()
```

```{code-cell}
h_value = []
for i in range(T):
h_value.append(model.get_value(h[i]))
Expand Down
2 changes: 2 additions & 0 deletions _sources/examples/optimal_power_flow.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ After optimization, we can retrieve the optimal solution:

```{code-cell}
model.optimize()
```

```{code-cell}
print(model.get_model_attribute(poi.ModelAttribute.TerminationStatus))

P_value = P.map(model.get_value)
Expand Down
6 changes: 6 additions & 0 deletions _sources/nonlinear.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ model.add_nl_constraint(con_f, nlfunc.Vars(x=x,y=y), ub = [4.0, -1.0])
model.add_nl_objective(obj_f, nlfunc.Vars(x=x,y=y))

model.optimize()
```

```{code-cell}
x_value = model.get_value(x)
y_value = model.get_value(y)

Expand Down Expand Up @@ -241,7 +243,9 @@ rosenbrock_f = model.register_function(rosenbrock)
model.add_nl_objective(rosenbrock_f, nlfunc.Vars(x=x, y=y))

model.optimize()
```

```{code-cell}
x_value = model.get_value(x)
y_value = model.get_value(y)

Expand Down Expand Up @@ -286,7 +290,9 @@ for i in range(N):
model.add_linear_constraint(t[i+1] - t[i] - 0.5 * h * u[i+1] - 0.5 * h * u[i] , poi.Eq, 0.0)

model.optimize()
```

```{code-cell}
objective_value = model.get_model_attribute(poi.ModelAttribute.ObjectiveValue)

print(f"Objective value: {objective_value}")
Expand Down
12 changes: 6 additions & 6 deletions constraint.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ <h1>Constraint<a class="headerlink" href="#constraint" title="Link to this headi
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2024-11-27 17:18:09 [INFO] checks license for COPT v7.2.2 20241023
2024-11-27 17:18:09 [WARN] no license files in current working folder: /home/runner/work/PyOptInterface/PyOptInterface/docs/source
2024-11-27 17:18:09 [WARN] no license files in binary folder: /opt/hostedtoolcache/Python/3.12.7/x64/bin
2024-11-27 17:18:09 [WARN] no license files in HOME folder: /home/runner/copt
2024-11-27 17:18:09 [INFO] empty environment variable: COPT_LICENSE_DIR
2024-11-27 17:18:09 [WARN] no license files in EV &#39;COPT_LICENSE_DIR&#39;:
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2024-11-27 17:28:19 [INFO] checks license for COPT v7.2.2 20241023
2024-11-27 17:28:19 [WARN] no license files in current working folder: /home/runner/work/PyOptInterface/PyOptInterface/docs/source
2024-11-27 17:28:19 [WARN] no license files in binary folder: /opt/hostedtoolcache/Python/3.12.7/x64/bin
2024-11-27 17:28:19 [WARN] no license files in HOME folder: /home/runner/copt
2024-11-27 17:28:19 [INFO] empty environment variable: COPT_LICENSE_DIR
2024-11-27 17:28:19 [WARN] no license files in EV &#39;COPT_LICENSE_DIR&#39;:

No license found. Starting COPT with size limitations for non-commercial use
Please apply for a license from www.shanshu.ai/copt
Expand Down
25 changes: 17 additions & 8 deletions examples/optimal_control_rocket.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ <h2>Implementation<a class="headerlink" href="#implementation" title="Link to th
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">model</span><span class="o">.</span><span class="n">optimize</span><span class="p">()</span>

<span class="n">h_value</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">T</span><span class="p">):</span>
<span class="n">h_value</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_value</span><span class="p">(</span><span class="n">h</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Optimal altitude: &quot;</span><span class="p">,</span> <span class="n">h_value</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -483,11 +477,26 @@ <h2>Implementation<a class="headerlink" href="#implementation" title="Link to th
Number of equality constraint Jacobian evaluations = 24
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 23
Total CPU secs in IPOPT (w/o function evaluations) = 0.111
Total CPU secs in IPOPT (w/o function evaluations) = 0.108
Total CPU secs in NLP function evaluations = 0.004

EXIT: Optimal Solution Found.
Optimal altitude: 1.012779392216388
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">h_value</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">T</span><span class="p">):</span>
<span class="n">h_value</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_value</span><span class="p">(</span><span class="n">h</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Optimal altitude: &quot;</span><span class="p">,</span> <span class="n">h_value</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Optimal altitude: 1.012779392216388
</pre></div>
</div>
</div>
Expand Down
43 changes: 26 additions & 17 deletions examples/optimal_power_flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,6 @@ <h2>Implementation<a class="headerlink" href="#implementation" title="Link to th
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">model</span><span class="o">.</span><span class="n">optimize</span><span class="p">()</span>

<span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_model_attribute</span><span class="p">(</span><span class="n">poi</span><span class="o">.</span><span class="n">ModelAttribute</span><span class="o">.</span><span class="n">TerminationStatus</span><span class="p">))</span>

<span class="n">P_value</span> <span class="o">=</span> <span class="n">P</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_value</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Optimal active power output of the generators:&quot;</span><span class="p">)</span>

<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">N_gen</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Generator </span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">P_value</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -592,13 +583,6 @@ <h2>Implementation<a class="headerlink" href="#implementation" title="Link to th
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
20 1.4997039e+04 9.74e-09 2.33e-05 -8.6 1.52e-03 - 1.00e+00 9.99e-01h 1
21 1.4997039e+04 5.94e-12 2.83e-12 -8.6 1.03e-03 - 1.00e+00 1.00e+00f 1
TerminationStatusCode.LOCALLY_SOLVED
Optimal active power output of the generators:
Generator 0: 0.4
Generator 1: 1.7
Generator 2: 1.9623464660959797
Generator 3: 0.0
Generator 4: 6.0

Number of Iterations....: 21

Expand All @@ -617,14 +601,39 @@ <h2>Implementation<a class="headerlink" href="#implementation" title="Link to th
Number of equality constraint Jacobian evaluations = 22
Number of inequality constraint Jacobian evaluations = 22
Number of Lagrangian Hessian evaluations = 21
Total CPU secs in IPOPT (w/o function evaluations) = 0.006
Total CPU secs in IPOPT (w/o function evaluations) = 0.007
Total CPU secs in NLP function evaluations = 0.000

EXIT: Optimal Solution Found.
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_model_attribute</span><span class="p">(</span><span class="n">poi</span><span class="o">.</span><span class="n">ModelAttribute</span><span class="o">.</span><span class="n">TerminationStatus</span><span class="p">))</span>

<span class="n">P_value</span> <span class="o">=</span> <span class="n">P</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">get_value</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Optimal active power output of the generators:&quot;</span><span class="p">)</span>

<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">N_gen</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Generator </span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">P_value</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>TerminationStatusCode.LOCALLY_SOLVED
Optimal active power output of the generators:
Generator 0: 0.4
Generator 1: 1.7
Generator 2: 1.9623464660959797
Generator 3: 0.0
Generator 4: 6.0
</pre></div>
</div>
</div>
</div>
<p>As shown by the result, the generator with less cost efficient has the highest active power output. The total generation power is also greater than the total demand due to the network loss.</p>
</section>
</section>
Expand Down
8 changes: 4 additions & 4 deletions expression.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ <h2>Efficient expression construction<a class="headerlink" href="#efficient-expr
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 642 μs, sys: 99 μs, total: 741 μs
Wall time: 744 μs
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 593 μs, sys: 129 μs, total: 722 μs
Wall time: 726 μs
</pre></div>
</div>
</div>
Expand All @@ -374,8 +374,8 @@ <h2>Efficient expression construction<a class="headerlink" href="#efficient-expr
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 18 ms, sys: 0 ns, total: 18 ms
Wall time: 17.9 ms
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 17.6 ms, sys: 341 μs, total: 17.9 ms
Wall time: 17.8 ms
</pre></div>
</div>
</div>
Expand Down
Loading

0 comments on commit 96e2ead

Please sign in to comment.