quicopt¶
The Python client for the Quicopt optimization service.
You describe a decision: what you get to choose, what has to hold, and what you want as much (or as little) of as possible. Quicopt finds the best choice there is.
Write the model with the Python modeling library you already use —
Pyomo,
OR-Tools MathOpt or
PuLP — and solve encodes it, sends it to the
service and hands back the answer. There is no solver on your machine.
Reading and encoding a model (ir + wire) needs nothing outside the standard
library; support for each modeling library is an optional extra.
Install¶
pip install quicopt # the model and the encoder — standard library only
pip install "quicopt[pyomo]" # + read models written in Pyomo
pip install "quicopt[mathopt]" # + read models written in OR-Tools MathOpt
pip install "quicopt[pulp]" # + read models written in PuLP
Quickstart¶
import pyomo.environ as pyo
from quicopt import Client
m = pyo.ConcreteModel()
m.x = pyo.Var(bounds=(0.1, 10))
m.obj = pyo.Objective(expr=m.x**2 + 1.0 / m.x, sense=pyo.minimize)
client = Client(api_key="…") # the key from your sign-up email
result = client.solve(m) # read the model, encode it, solve it
print(result.status, result.objective, result.solution)
print(result.display) # the service's ready-to-print summary
The service needs an API key. Register at https://quicopt.com/signup and the key arrives by email. To keep the key out of your code, set the environment variable QUICOPT_API_KEY instead and create the client as Client().
solve takes the model as it stands (Pyomo, OR-Tools
MathOpt, or PuLP) and reads it into Quicopt's own form on the way out. For a long
solve, submit returns a Job
handle to poll. Pass project="…" to tag a call for per-project invoicing; which
modeling library you wrote in is recorded automatically.
If you want the encoded model yourself — to inspect it or send it by another route —
build a Program (directly, or with one of the
import_model functions) and call encode.
How it fits together¶
your model ──import_model──▶ Program ──encode──▶ bytes ──▶ service
(Pyomo, the same what travels
MathOpt, PuLP) model as over the network
plain data
Program is what a model is to Quicopt, whichever library wrote it: variables,
expressions and constraints as data. Its schema is published
(protobuf), so those bytes mean the same thing to the
Python, Julia and Ruby clients alike.
See the API reference for each step:
ir— the intermediate representation: theProgram, a model as plain data.wire—Program→ the bytes the service reads.pyomo— a Pyomo model →Program.stochastic— writing a model whose data is not known when the decision is made.structured— orderings such as a route, splits into groups, deliveries of none or at least a minimum load, fees, and data read at positions the service chooses.mathopt— an OR-Tools MathOpt model →Program.pulp— a PuLP model →Program.client— POST those bytes and read the result back.