Skip to content

Commit

Permalink
constraint ordering and pint printing consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Aug 10, 2020
1 parent 107c47e commit cc98d02
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/source/examples/autosweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
l_vals = np.linspace(1, 10, 10)
sol1 = bst1.sample_at(l_vals)
print("values of l: %s" % l_vals)
print("values of A: %s" % sol1("A"))
print("values of A: [%s] %s" %
(" ".join("% .1f" % n for n in sol1("A").magnitude), sol1("A").units))
cost_estimate = sol1["cost"]
cost_lb, cost_ub = sol1.cost_lb(), sol1.cost_ub()
print("cost lower bound:\n%s\n" % cost_lb)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/autosweep_output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Solved after 33 passes, cost logtol +/-0.000992
values of l: [ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
values of A: [ 1.99999973 5.00052732 10.00251992 17.00358613 26.0083274 37.00812871 50.0199693 65.02146472 82.03758369 100.99995485] meter ** 2
values of A: [ 2.0 5.0 10.0 17.0 26.0 37.0 50.0 65.0 82.0 101.0] meter ** 2
cost lower bound:
[3.99999897e+00 2.49990635e+01 9.99519417e+01 2.88964405e+02
6.75761038e+02 1.36887689e+03 2.49888336e+03 4.22418997e+03
Expand Down
20 changes: 10 additions & 10 deletions docs/source/examples/performance_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def setup(self, aircraft):
self.Wburn = self.aircraftp.Wburn
self.Wfuel = self.aircraftp.Wfuel

return {"flightstate": self.flightstate,
"aircraft performance": self.aircraftp}
return {"aircraft performance": self.aircraftp,
"flightstate": self.flightstate}


class Mission(Model):
Expand Down Expand Up @@ -179,12 +179,12 @@ def setup(self, wing, state):
mu = state.mu

return {
"drag model":
CD >= 0.074/Re**0.2 + CL**2/np.pi/A/e,
"definition of D":
D >= 0.5*rho*V**2*CD*S,
"definition of Re":
Re == rho*V*c/mu,
"definition of D":
D >= 0.5*rho*V**2*CD*S}
"drag model":
CD >= 0.074/Re**0.2 + CL**2/np.pi/A/e}


class Wing(Model):
Expand All @@ -208,10 +208,10 @@ class Wing(Model):
"""
@parse_variables(__doc__, globals())
def setup(self):
return {"parametrization of wing weight":
W >= S*rho,
"definition of mean chord":
c == (S/A)**0.5}
return {"definition of mean chord":
c == (S/A)**0.5,
"parametrization of wing weight":
W >= S*rho}

dynamic = WingAero

Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/performance_modeling_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Constraints

FlightSegment
AircraftP
"fuel burn rate":
Wburn[:] >= 0.1·D[:]
"lift":
Aircraft.W + Wfuel[:] <= 0.5·rho[:]·CL[:]·S·V[:]²
"fuel burn rate":
Wburn[:] >= 0.1·D[:]
"performance":
WingAero
"definition of D":
Expand Down
8 changes: 4 additions & 4 deletions gpkit/constraints/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __init__(self, original_constraints):
for c in original_constraints.flat()]

ConstraintSet.__init__(self, {
"relaxed constraints": relaxed_constraints,
"minimum relaxation": self.relaxvar >= 1}, original_substitutions)
"minimum relaxation": self.relaxvar >= 1,
"relaxed constraints": relaxed_constraints}, original_substitutions)


class ConstraintsRelaxed(ConstraintSet):
Expand Down Expand Up @@ -78,8 +78,8 @@ def __init__(self, original_constraints):
for i, c in enumerate(original_constraints.flat())]

ConstraintSet.__init__(self, {
"relaxed constraints": relaxed_constraints,
"minimum relaxation": self.relaxvars >= 1}, original_substitutions)
"minimum relaxation": self.relaxvars >= 1,
"relaxed constraints": relaxed_constraints}, original_substitutions)


class ConstantsRelaxed(ConstraintSet):
Expand Down
3 changes: 2 additions & 1 deletion gpkit/interactive/sankey.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"implements Sankey"
from collections import defaultdict, Iterable
from collections import defaultdict
from collections.abc import Iterable
import numpy as np
from ipywidgets import Layout
from ipysankeywidget import SankeyWidget # pylint: disable=import-error
Expand Down

0 comments on commit cc98d02

Please sign in to comment.