Skip to content

Commit

Permalink
py3.7 sankeys, example fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Aug 14, 2020
1 parent fd54c46 commit 35e11b9
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 37 deletions.
3 changes: 2 additions & 1 deletion docs/source/examples/checking_result_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
m = Model(objective, constraints)

# solve the model
sol = m.solve()
# verbosity is 0 for testing's sake, no need to do that in your code!
sol = m.solve(verbosity=0)

# save the current state of the model
sol.save("last_verified.sol")
Expand Down
4 changes: 0 additions & 4 deletions docs/source/examples/checking_result_changes_output.txt
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
Using solver 'cvxopt'
for 2 free variables
in 4 posynomial inequalities.
Solving took 0.0159 seconds.
1 change: 1 addition & 0 deletions docs/source/examples/freeing_fixed_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
x = Variable("x")
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"]

assert abs(sol["cost"] - 4) <= 1e-4
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/freeing_fixed_variables_output.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Using solver 'cvxopt'
for 1 free variables
in 2 posynomial inequalities.
Solving took 0.00911 seconds.
Solving took 0.00866 seconds.
Using solver 'cvxopt'
for 2 free variables
in 3 posynomial inequalities.
Solving took 0.0116 seconds.
Solving took 0.0101 seconds.
4 changes: 2 additions & 2 deletions docs/source/examples/gettingstarted.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
### Example variable sensitivity usage
x = Variable("x")
x_min = Variable("x_{min}", 2)
sol = Model(x, [x_min <= x]).solve()
sol = Model(x, [x_min <= x]).solve(verbosity=0)
sens_x_min = sol["sensitivities"]["variables"][x_min]

x = Variable("x")
x_squared_min = Variable("x^2_{min}", 2)
sol = Model(x, [x_squared_min <= x**2]).solve()
sol = Model(x, [x_squared_min <= x**2]).solve(verbosity=0)
sens_x_min = sol["sensitivities"]["variables"][x_squared_min]
8 changes: 0 additions & 8 deletions docs/source/examples/gettingstarted_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@ Most Sensitive Constraints
+0.17 : x ≥ 2·y

The optimal value is 0.005511353595523829.
Using solver 'cvxopt'
for 1 free variables
in 2 posynomial inequalities.
Solving took 0.0088 seconds.
Using solver 'cvxopt'
for 1 free variables
in 2 posynomial inequalities.
Solving took 0.0104 seconds.
64 changes: 44 additions & 20 deletions docs/source/figures/documentation sankeys.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,30 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/tao/projects/ce/venv/local/lib/python3.5/site-packages/pint/quantity.py:1377: UnitStrippedWarning: The unit of the quantity is stripped.\n",
" warnings.warn(\"The unit of the quantity is stripped.\", UnitStrippedWarning)\n"
"/home/tao/projects/ce/py3.7/lib/python3.7/site-packages/gpfit/fit_constraintset.py:46: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" for k in range(fitdata[\"K\"])]\n",
"/home/tao/projects/ce/py3.7/lib/python3.7/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" return array(a, dtype, copy=False, order=order)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: skipped auto-differentiation of linked variable Aircraft.Wing.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.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"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/tao/projects/ce/gpkit/gpkit/constraints/prog_factories.py:23: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.\n",
" array_calulated[v.veckey] = np.array(ofn(kdc))\n"
]
},
{
Expand All @@ -53,7 +75,7 @@
" in 23 locally-GP constraints\n",
" and for 1032 free variables\n",
" in 1384 posynomial inequalities.\n",
"Solving took 1.29 seconds and 4 GP solves.\n",
"Solving took 1.28 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 All @@ -63,8 +85,10 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/tao/projects/ce/venv/local/lib/python3.5/site-packages/pint/quantity.py:1377: UnitStrippedWarning: The unit of the quantity is stripped.\n",
" warnings.warn(\"The unit of the quantity is stripped.\", UnitStrippedWarning)\n"
"/home/tao/projects/ce/py3.7/lib/python3.7/site-packages/numpy/core/_asarray.py:136: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.\n",
" return array(a, dtype, copy=False, order=order, subok=True)\n",
"/home/tao/projects/ce/py3.7/lib/python3.7/site-packages/numpy/core/fromnumeric.py:87: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.\n",
" return ufunc.reduce(obj, axis, dtype, out, **passkwargs)\n"
]
}
],
Expand All @@ -84,12 +108,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "df02a5fc4e5b454487bb7fc6c97b7714",
"model_id": "e7b89175684c40a9847107e9be98ede6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'target': 'Mission', 'source': 'Mission.0001',…"
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'Mission.0001', 'target': 'Mission',…"
]
},
"metadata": {},
Expand All @@ -113,12 +137,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ebfa436a0899442cb726197d54f5f3f0",
"model_id": "f2e8bb63a12d4d5490f56d61cc51e84c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'target': 'b [ft].0001.0003', 'source': 'b [ft"
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'b [ft].0001.0001.0014.0002', 'targe"
]
},
"metadata": {},
Expand All @@ -137,12 +161,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "10a90f3a45e6457c80f21b9d13d87598",
"model_id": "6c7618d71dd349b4b130afa613d6f1a6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'target': 'Wtotal [lbf].0001.0002', 'source': …"
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'Wtotal [lbf].0002', 'target': 'Wtot"
]
},
"metadata": {},
Expand All @@ -161,12 +185,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "155a99723c68418e9e46bd5d6b7f0363",
"model_id": "3663b7ed2f014a4bbd5de4403548d091",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'target': 'Nprop.0001', 'source': 'Nprop.0001."
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'Nprop.0001.0001.0011', 'target': 'N"
]
},
"metadata": {},
Expand All @@ -185,12 +209,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "025b6a627b26428e999b0da8bb413f43",
"model_id": "1f174e1129fd4997a86907f5852afa02",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'target': 'CFRPFabric.tmin [mm].0001.0001.0016"
"SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'CFRPFabric.tmin [mm].0001.0001.0014"
]
},
"metadata": {},
Expand All @@ -209,12 +233,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "af994c4ce1f04d3f9a31a0729749ccc0",
"model_id": "81575a60603848a68073c6d90f96ad0b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='700', width='1000'), links=[{'target': 'SolarMission.0003', 'source': 'Sola"
"SankeyWidget(layout=Layout(height='700', width='1000'), links=[{'source': 'SolarMission.0001.0021', 'target': …"
]
},
"metadata": {},
Expand All @@ -238,12 +262,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ba91292ed7b34b4ca858dcb02e2a5d60",
"model_id": "96fc20dcc7434561b85a725420a58bdf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SankeyWidget(layout=Layout(height='400', width='1200'), links=[{'target': 'Model.0001.0002.0002.0003.0001', 's"
"SankeyWidget(layout=Layout(height='400', width='1200'), links=[{'source': 'Model.0001.0001.0001', 'target': 'M"
]
},
"metadata": {},
Expand Down Expand Up @@ -520,7 +544,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.7.8"
}
},
"nbformat": 4,
Expand Down
Binary file modified docs/source/figures/sankey_autosaves/Mission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/figures/sankey_autosaves/Model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/figures/sankey_autosaves/SolarMission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/figures/sankey_autosaves/SolarMission_Nprop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/figures/sankey_autosaves/SolarMission_Wtotal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 35e11b9

Please sign in to comment.