https://github.com/nariaki3551/pulp2localsolver
A PuLP to LocalSolver converter
https://github.com/nariaki3551/pulp2localsolver
localsolver optimization pulp
Last synced: about 1 year ago
JSON representation
A PuLP to LocalSolver converter
- Host: GitHub
- URL: https://github.com/nariaki3551/pulp2localsolver
- Owner: nariaki3551
- License: mit
- Created: 2023-04-19T12:56:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-19T13:00:19.000Z (about 3 years ago)
- Last Synced: 2025-05-04T23:25:16.367Z (about 1 year ago)
- Topics: localsolver, optimization, pulp
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pulp2localsolver
A PuLP to LocalSolver converter
## Install
```
git clone https://github.com/nariaki3551/pulp2localsolver.git
cd pulp2localsolver
pip install .
```
## Setting
You have to install Python interface of LocalSolver.
Please read this document https://www.localsolver.com/docs/last/installation/pythonsetup.html ,
and install localsolver python package.
## Usage
```python
import pulp
# create pulp LpProblem
prob = pulp.LpProblem("sample")
# define variables
x = pulp.LpVariable("x", lowBound=0, upBound=10)
y = pulp.LpVariable("y", lowBound=0, upBound=10)
z = pulp.LpVariable("z", cat="Binary")
# set objective
prob += x + y + z + 1
# set constraints
prob += 3 * x + 5 * y <= 15
prob += 2 * x + y >= 4
prob += x - y == 1
print(prob)
# solve problem using LocalSolver
# and decode solution to pulp variable objects
import pulp2localsolver
pulp2localsolver.localsolver_solve(prob)
print("Result")
print("x", x.value())
print("y", y.value())
print("z", z.value())
print("obj", prob.objective.value())
```