Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 committed Mar 23, 2024
1 parent 051a5b8 commit 30b098f
Show file tree
Hide file tree
Showing 10 changed files with 798 additions and 718 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__
*.egg-info
dist

.pytest_cache/

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ sum(X)
```

Note that variables are considered equal if they have the same name, so
for examples this expression:
for example this expression:

```python
Variable("x") + 2 + Variable("x")
```

will be treated as simply `2*x+2`.

The first argument to `minimize` and `maximize` is the objective function which must be either a single variable or a linear combination as in the example above.
The first argument to `minimize` and `maximize` is the objective function which must be either a single variable or a linear combination as in the examples above.

### Constraints

Expand All @@ -97,7 +97,7 @@ There is no need to convert your constraints to the canonical form which uses on

The return value of `minimize` and `maximize` is a 2-tuple containing the value of the objective function and a dictionary of variables and their values.

The functions may raise `pivotal.Infeasible` if the program is over-constrained (no solution exists) or `pivotal.Unbounded` if the program is under-constrained (the objective can be made arbitrarily small).
The functions may raise `pivotal.Infeasible` if the program is over-constrained (no solution exists) or `pivotal.Unbounded` if the program is under-constrained (the objective can be made arbitrarily small):

```python
from pivotal import minimize, maximize, Variable, Infeasible
Expand All @@ -123,13 +123,15 @@ except Infeasible:

## Limitations

- Currently, all variables are assumed to be positive
- Currently, all variables are assumed to be nonnegative i.e. x >= 0.

## TODO (Contributions welcome)

- ✔️ Setting tolerance & max number of iterations
- (WIP) Arbitrary variable bounds, e.g. `a <= x <= b`
- (WIP) Support for absolute values
- (WIP) Support for absolute values using Python's `abs()`
- in the objective function
- in constraints
- MILP solver with branch & bound


Expand Down
3 changes: 2 additions & 1 deletion pivotal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pivotal.api import Variable, maximize, minimize
from pivotal.api import maximize, minimize
from pivotal.errors import Infeasible, Unbounded
from pivotal.expressions import Variable


__version__ = "0.0.3"
Expand Down
Loading

0 comments on commit 30b098f

Please sign in to comment.