Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Jan 8, 2022
1 parent 3752cd9 commit c558659
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/source/debugging.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Debugging Models
****************

A number of errors and warnings may be raised when attempting to solve a model.
A number of errors and warnings may be raised when attempting to solve a model.
A model may be primal infeasible: there is no possible solution that satisfies all constraints. A model may be dual infeasible: the optimal value of one or more variables is 0 or infinity (negative and positive infinity in logspace).

For a GP model that does not solve, solvers may be able to prove its primal or dual infeasibility, or may return an unknown status.
Expand All @@ -11,6 +11,7 @@ GPkit contains several tools for diagnosing which constraints and variables migh
.. literalinclude:: examples/debug.py

.. literalinclude:: examples/debug_output.txt
:language: breakdowns

Note that certain modeling errors (such as omitting or forgetting a constraint) may be difficult to diagnose from this output.

Expand All @@ -33,7 +34,7 @@ Potential errors and warnings
- ``RuntimeWarning: Dual cost nan does not match primal cost 1.00122315152``
- Similarly to the above, this warning may be seen in dual infeasible models, see *Dual Infeasibility* below.

..
..
note: remove the above when we match solver tolerance in GPkit (issue #753)

Expand All @@ -54,6 +55,7 @@ For example, Mosek returns ``DUAL_INFEAS_CER`` when attempting to solve the foll
Upon viewing the printed output,

.. literalinclude:: examples/unbounded_output.txt
:language: breakdowns

The problem, unsurprisingly, is that the cost ``1/x`` has no lower bound because ``x`` has no upper bound.

Expand Down Expand Up @@ -84,3 +86,4 @@ If you suspect your model is primal infeasible, you can find the nearest primal
.. literalinclude:: examples/relaxation.py

.. literalinclude:: examples/relaxation_output.txt
:language: breakdowns
5 changes: 5 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ minimize :math:`x` subject to the constraint :math:`x \ge 1`.
Of course, the optimal value is 1. Output:

.. literalinclude:: examples/x_greaterthan_1_output.txt
:language: breakdowns

Maximizing the Volume of a Box
==============================
Expand All @@ -27,6 +28,7 @@ This example comes from Section 2.4 of the `GP tutorial <http://stanford.edu/~bo
The output is

.. literalinclude:: examples/simple_box_output.txt
:language: breakdowns

Water Tank
==========
Expand All @@ -37,6 +39,7 @@ Say we had a fixed mass of water we wanted to contain within a tank, but also wa
The output is:

.. literalinclude:: examples/water_tank_output.txt
:language: breakdowns

Simple Wing
===========
Expand All @@ -47,6 +50,7 @@ This example comes from Section 3 of `Geometric Programming for Aircraft Design
The output is:

.. literalinclude:: examples/simpleflight_output.txt
:language: breakdowns

Simple Beam
===========
Expand All @@ -57,6 +61,7 @@ In this example we consider a beam subjected to a uniformly distributed transver
The output is:

.. literalinclude:: examples/beam_output.txt
:language: breakdowns

By plotting the deflection, we can see that the agreement between the analytical solution and the GP solution is good.

Expand Down
6 changes: 5 additions & 1 deletion docs/source/examples/breakdowns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"An example to show off Breakdowns"
import os
import sys
import pickle
from gpkit.breakdowns import Breakdowns

Expand All @@ -11,7 +12,10 @@

print("Cost breakdown (you may be familiar with this from solution tables)")
print("==============")
bds.plot("cost")
try:
bds.plot("cost")
except AttributeError: # if the pint version differs from the pickled solution
sys.exit(0)

print("Variable breakdowns (note the two methods of access)")
print("===================")
Expand Down
3 changes: 3 additions & 0 deletions docs/source/modelbuilding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ These methods are illustrated in the following example.
.. literalinclude:: examples/model_var_access.py

.. literalinclude:: examples/model_var_access_output.txt
:language: breakdowns

Vectorization
=============
Expand All @@ -49,6 +50,7 @@ This allows models written with scalar constraints to be created with vector con
.. literalinclude:: examples/vectorize.py

.. literalinclude:: examples/vectorize_output.txt
:language: breakdowns



Expand All @@ -70,3 +72,4 @@ The :ref:`sensitivity diagram <sankey>` which this code outputs shows how it is
Note that the output table has been filtered above to show only variables of interest.

.. literalinclude:: examples/performance_modeling_output.txt
:language: breakdowns
2 changes: 2 additions & 0 deletions docs/source/signomialprogramming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This problem is not GP compatible due to the :math:`sin(x)` constraint. One app
.. literalinclude:: examples/sin_approx_example.py

.. literalinclude:: examples/sin_approx_example_output.txt
:language: breakdowns

Assume we have some external code which is capable of evaluating our incompatible function:

Expand All @@ -69,6 +70,7 @@ and replace the incompatible constraint in our GP:
.. literalinclude:: examples/external_sp.py

.. literalinclude:: examples/external_sp_output.txt
:language: breakdowns

which is the expected result. This method has been generalized to larger problems, such as calling XFOIL and AVL.

Expand Down

0 comments on commit c558659

Please sign in to comment.