<commit_before># gpkit #

Python tools for defining and manipulating geometric programming models.

Interfaces with either the [MOSEK](http://mosek.com) or [CVXopt](http://cvxopt.org/) solvers.

Installation instructions are below.

## Introduction ##

### What does gpkit look like?

Excerpt from an [aircraft design application](http://nbviewer.ipython.org/github/appliedopt/gpkit/blob/master/examples/ipynb/simpleaircraft.ipynb):

```python
# Note: in Python, '**' serves as the power ('^') operator

gpkit.GP( # minimize                            # What's the lowest
         0.5*rho*S*C_D*V**2,                    # [N] TOTAL DRAG FORCE
         [ # subject to                         # That we can get, with our
          Re <= (rho/mu)*V*(S/A)**0.5,          # flow characteristics,
          C_f >= 0.074/Re**0.2,                 # turbulent BL approximation,
          C_D >= C_D_fuse + C_D_wpar + C_D_ind  # the above 'drag model',
          W <= 0.5*rho*S*C_L*V**2,              # flight at cruising,
          W <= 0.5*rho*S*C_Lmax*V_min**2,       # flight at takeoff,     
          W >= W_0 + W_w,                       # the plane's weight, and
          W_w >= W_w_surf + W_w_strc,           # the above 'wing-weight model'?
         ], solver='mosek')
 ```

### What can a geometric program do?

A geometric program (GP) can solve any optimization problem where [posynomials](http://en.wikipedia.org/wiki/Posynomial) form both the cost function (what you're trying to minimize or maximize, e.g. airplane fuel consumption) and the constraints (equations that have to be true, e.g. that the plane can take off). 

### Why are geometric programs useful?

It turns out that [they have some nice mathematical properties](http://stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf):
  - it's easy to check if something is a posynomial
  - they're quick to solve, which is good for large problems and trade-off analysis
  - solving a GP gives you an auomatic sensitivity analysis (via its dual)
  - infeasible GP can be examined to figure out how infeasible they are and which constraints are causing the most trouble

Geometric programs might also have nice social properties:
  - it's clear when you can't turn an equation into a posynomial;
    - this categorizes the design space into variables computers should definitely be choosing, and those that might be harder to solve for
  - many engineering equations are already posynomials
  - posynomial models written by different people are easy to bring together;
      - adding a new model won't bring the whole optimization down

## Installation ##

1. Install [Anaconda](http://continuum.io/downloads) for your platform
   - (Mac) Install the Apple Developer Tools first
   - If you don't want to install Anaconda, the packages useful for running gpkit are numpy, scipy, sympy, and ipython notebook
2. Install ctypesgen by entering `pip install ctypesgen` at a terminal
  - (Windows) use an "Anaconda Command Prompt" instead
3. Install a solve: gpkit currently supports both CVXOPT and MOSEK:
  - [CVXOPT](http://cvxopt.org/download/index.html) 
    - (Mac/Linux) Run `python setup.py install` in the `cvxopt` folder, as noted [here](http://cvxopt.org/install/index.html#standard-installation)
    - (Windows) Follow the steps [here](http://cvxopt.org/install/index.html#building-cvxopt-for-windows)
  -  [MOSEK](http://mosek.com/resources/downloads)
    -  (Mac/Linux) Move the `mosek` folder to your home directory
5. Get a MOSEK [academic license file](http://license.mosek.com/academic)
  - (Mac/Linux) Put the license file in ~/mosek/
  - (Windows) Put the license file in `Users/$USERNAME/mosek`, creating that folder if necessary
6. Download gpkit
7. Run `python build.py` in the gpkit folder
8. Test your install by running `ipython -c "%run gpkit/tests/run_tests.py"`<commit_msg>README typos and tweaks<commit_after># gpkit #

Python package for defining and manipulating geometric programming models.

Interfaces with multiple solvers -- currently [MOSEK](http://mosek.com) and [CVXopt](http://cvxopt.org/) are supported.

Installation instructions are below.

## Introduction ##

### What does gpkit look like?

Excerpt from an [aircraft design application](http://nbviewer.ipython.org/github/appliedopt/gpkit/blob/master/examples/ipynb/simpleaircraft.ipynb):

```python
# Note: in Python, '**' serves as the power ('^') operator

gpkit.GP( # minimize                            # What's the lowest
         0.5*rho*S*C_D*V**2,                    # [N] TOTAL DRAG FORCE
         [ # subject to                         # That we can get, with our
          Re <= (rho/mu)*V*(S/A)**0.5,          # flow characteristics,
          C_f >= 0.074/Re**0.2,                 # turbulent BL approximation,
          C_D >= C_D_fuse + C_D_wpar + C_D_ind  # the above 'drag model',
          W <= 0.5*rho*S*C_L*V**2,              # flight at cruising,
          W <= 0.5*rho*S*C_Lmax*V_min**2,       # flight at takeoff,     
          W >= W_0 + W_w,                       # the plane's weight, and
          W_w >= W_w_surf + W_w_strc,           # the above 'wing-weight model'?
         ], solver='mosek')
 ```

### What can a geometric program do?

A geometric program (GP) can solve any optimization problem where [posynomials](http://en.wikipedia.org/wiki/Posynomial) form both the cost function (what you're trying to minimize or maximize, e.g. airplane fuel consumption) and the constraints (relationships that have to be true, e.g. that the plane can take off). 

### Why are geometric programs useful?

It turns out that [they have some nice mathematical properties](http://stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf):
  - it's easy to check if something is a posynomial
  - they're quick to solve, which is good for large problems and trade-off analysis
  - solving a GP gives you an automatic sensitivity analysis (via its dual)
  - an infeasible GP can be examined to figure out how infeasible it is and which constraints are causing the most trouble

Geometric programs might also have nice social properties:
  - it's clear when you can't turn an equation into a posynomial;
    - this categorizes the design space into variables computers should definitely be choosing, and those that might be harder to solve for
  - many engineering equations are already posynomials
  - posynomial models written by different people are easy to bring together;
      - adding a new model won't bring the whole optimization down

## Installation ##

1. Install [Anaconda](http://continuum.io/downloads) for your platform
   - (Mac) Install the Apple Developer Tools first
   - If you don't want to install Anaconda, the packages useful for running gpkit are numpy, scipy, sympy, and ipython notebook
2. Install ctypesgen by entering `pip install ctypesgen` at a terminal
  - (Windows) use an "Anaconda Command Prompt" instead
3. Install a solver: gpkit currently supports both CVXOPT and MOSEK. Note: if you wish to run the unit test suite, both solvers must be installed.
  - [CVXOPT](http://cvxopt.org/download/index.html) 
    - (Mac/Linux) Run `python setup.py install` in the `cvxopt` folder, as noted [here](http://cvxopt.org/install/index.html#standard-installation)
    - (Windows) Follow the steps [here](http://cvxopt.org/install/index.html#building-cvxopt-for-windows)
  -  [MOSEK](http://mosek.com/resources/downloads)
    -  (Mac/Linux) Move the `mosek` folder to your home directory
5. Get a MOSEK [academic license file](http://license.mosek.com/academic)
  - (Mac/Linux) Put the license file in ~/mosek/
  - (Windows) Put the license file in `Users/$USERNAME/mosek`, creating that folder if necessary
6. Clone gpkit
7. Run `python build.py` in the gpkit folder
8. Test your install by running `ipython -c "%run gpkit/tests/run_tests.py"`
{'fraction_non_alphanumeric': 0.09939874632211845, 'fraction_numerical': 0.006396315722144045, 'mean_word_length': 3.1343204653622423, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1608595', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2293, 'n_words': 874}