from gpkit import Variable, VectorVariable  # Demonstration of nomenclature syntax
# 
# Lines that end in "Variables" will be parsed as a scalar variable table
# until the next blank line.
# 
# Variables
# ---------
A = self.A = Variable('A', 'm^2', 'surface area')  # from 'A       [m^2]  surface area'
V = self.V = Variable('V', 100, 'L', 'minimum volume')  # from 'V   100 [L]    minimum volume'
# 
# Lines that end in "Variables of length $N" will be parsed as vector
# variables of length $N until the next blank line.
# 
# Variables of length 3
# ---------------------
s = self.s = VectorVariable(3, 's', 'm', 'side length')  # from 's       [m]    side length'
# 
# Let's introduce more variables: (any line ending in "Variables" is parsed)
# 
# Zoning Variables
# ----------------
h = self.h = Variable('h', 1, 'm', 'minimum height')  # from 'h     1 [m]    minimum height'
# 
# Upper Unbounded
# ---------------
# A
# 
# The ordering of these blocks doesn't affect anything; order them in the
# way that makes the most sense to someone else reading your model.
# 

          ┃┓          ┓          /┓
          ┃┃          ┃           ┃
          ┃┃          ┣╸s[0]     /┣╸h
     Cost╺┫┃          ┃ (0.316m)  ┃ (1m, fixed)
 (1.46m²) ┃┣╸A        ┛          /┛
          ┃┃ (1.46m²) ┓      ┓
          ┃┃          ┣╸s[2] ┣╸h
          ┃┛          ┛ (1m) ┛



      ┃┓
      ┃┃
      ┃┃
      ┃┃
      ┃┣╸A ≥ 2·(s[0]·s[1] + s[1]·s[2] + s[2]·s[0])
      ┃┃
      ┃┃
      ┃┛
      ┃┓
 Cube╺┫┃
      ┃┣╸V = 100l
      ┃┛
      ┃┓
      ┃┃
      ┃┣╸V ≤ s[:].prod()
      ┃┛
      ┃┣╸h = 1m
      ┃┛
      ┃┣╸s[2] ≥ h
      ┃┛


Optimal Cost
------------
Cube.A : 1.465 [m²]

Free Variables
--------------
Cube
   A : 1.465                   [m²] surface area
s[:] : [ 0.316  0.316  1     ] [m]  side length

Fixed Variables
---------------
Cube
V : 100 [l] minimum volume
h : 1   [m] minimum height

Variable Sensitivities
----------------------
Cube
V : +0.5683 minimum volume
h : +0.2952 minimum height

Most Sensitive Constraints
--------------------------
Cube
+1      : A ≥ 2·(s[0]·s[1] + s[1]·s[2] + s[2]·s[0])
+0.5683 : V ≤ s[:].prod()
+0.2952 : s[2] ≥ h
