Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Aug 14, 2020
1 parent 35e11b9 commit f37ea15
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/source/examples/freeing_fixed_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
y = Variable("y", 3) # fix value to 3
m = Model(x, [x >= 1 + y, y >= 1])
# verbosity is 0 for testing's sake, no need to do that in your code!
sol = m.solve() # optimal cost is 4; y appears in sol["constants"]
sol = m.solve(verbosity=0) # optimal cost is 4; y appears in sol["constants"]

assert abs(sol["cost"] - 4) <= 1e-4
assert y in sol["constants"]
Expand Down
64 changes: 44 additions & 20 deletions docs/source/figures/documentation sankeys.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
"Warning: skipped auto-differentiation of linked variable Aircraft.Empennage.HorizontalTail.Planform.cbarmac because NotImplementedError(\"Automatic differentiation not yet supported for <class 'pint.quantity.build_quantity_class.<locals>.Quantity'> objects\") was raised. Set `gpkit.settings[\"ad_errors_raise\"] = True` to raise such Exceptions directly.\n",
"\n",
"Warning: skipped auto-differentiation of linked variable Aircraft.Empennage.VerticalTail.Planform.cbarmac because NotImplementedError(\"Automatic differentiation not yet supported for <class 'pint.quantity.build_quantity_class.<locals>.Quantity'> objects\") was raised. Set `gpkit.settings[\"ad_errors_raise\"] = True` to raise such Exceptions directly.\n",
"\n"
"\n",
"Starting a sequence of GP solves\n",
" for 97 free variables\n",
" in 23 locally-GP constraints\n",
" and for 1032 free variables\n",
" in 1384 posynomial inequalities.\n"
]
},
{
Expand All @@ -70,12 +75,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Starting a sequence of GP solves\n",
" for 97 free variables\n",
" in 23 locally-GP constraints\n",
" and for 1032 free variables\n",
" in 1384 posynomial inequalities.\n",
"Solving took 1.28 seconds and 4 GP solves.\n",
"Solving took 1.3 seconds and 4 GP solves.\n",
"Warning: Variable Mission.Climb.AircraftDrag.WingAero.CL[:] could cause inaccurate result because it is below lower bound. Solution is 1.0302 but bound is 0.9465\n",
"Warning: Variable Mission.Climb.AircraftDrag.WingAero.Re[:] could cause inaccurate result because it is above upper bound. Solution is 1230806.2495 but bound is 600000.0000\n",
"Warning: Variable Mission.Climb.AircraftDrag.TailAero1.Re[:] could cause inaccurate result because it is above upper bound. Solution is 1152795.0157 but bound is 1000000.0000\n"
Expand Down Expand Up @@ -108,7 +108,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e7b89175684c40a9847107e9be98ede6",
"model_id": "f7674899347547bcbe724d1f6bb2af10",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -137,7 +137,31 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f2e8bb63a12d4d5490f56d61cc51e84c",
"model_id": "14c3f385c3684b0286408f8d59d4a1eb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'Mission.0001.0021', 'target': 'Miss…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"Sankey(sol, M).diagram(minsenss=1, maxlinks=30, left=130, showconstraints=False)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "472bc4a9882641ad894031d6b1bdd6cf",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -155,13 +179,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6c7618d71dd349b4b130afa613d6f1a6",
"model_id": "8b9c2ec1fb5d44698a5079afdba5b703",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -179,13 +203,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3663b7ed2f014a4bbd5de4403548d091",
"model_id": "0027a5530f21403dab17842217089def",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -203,13 +227,13 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1f174e1129fd4997a86907f5852afa02",
"model_id": "12db93e8a7e44ae782133c8c29a859e8",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -227,13 +251,13 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81575a60603848a68073c6d90f96ad0b",
"model_id": "e26c56693b414d83ad57334447475cc4",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -251,18 +275,18 @@
"reload(gpkit.interactive.sankey)\n",
"Sankey = gpkit.interactive.sankey.Sankey\n",
"\n",
"Sankey(sol, M, \"SolarMission\").diagram(maxlinks=30, showconstraints=False, height=700, left=100)"
"Sankey(sol, M, \"SolarMission\").diagram(maxlinks=30, showconstraints=False, height=700)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "96fc20dcc7434561b85a725420a58bdf",
"model_id": "3574d35d01464fe8a4bef3b16f1f16e8",
"version_major": 2,
"version_minor": 0
},
Expand Down
Binary file modified docs/source/figures/sankey_autosaves/Mission.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/source/figures/sankey_autosaves/Mission2.png
Binary file not shown.
Binary file modified docs/source/figures/sankey_autosaves/SolarMission.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
5 changes: 2 additions & 3 deletions docs/source/visint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ without any tight constraints or sensitive fixed variables.

.. code:: python
Sankey(sol, M, "SolarMission").diagram(maxlinks=30, showconstraints=False,
height=700, left=100)
Sankey(sol, M, "SolarMission").diagram(maxlinks=30, showconstraints=False, height=700)
.. figure:: figures/sankey_autosaves/SolarMission.png

Note that in addition to the ``left`` and ``showconstraints`` syntax introduced above,
Note that in addition to the ``showconstraints`` syntax introduced above,
this uses two additional arguments you may find useful when visualizing large models:
``height`` sets the height of the diagram in pixels (similarly for ``width``),
while ``maxlinks`` increases the maximum number of links (default 20), making
Expand Down
2 changes: 1 addition & 1 deletion gpkit/interactive/sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Iterable
import numpy as np
from ipywidgets import Layout
from ipysankeywidget import SankeyWidget # pylint: disable=import-error
from ipysankeywidget import SankeyWidget
from ..repr_conventions import lineagestr, unitstr
from .. import Model, GPCOLORS
from ..constraints.array import ArrayConstraint
Expand Down

0 comments on commit f37ea15

Please sign in to comment.