Skip to main content

Robust Stochastic Optimization Made Easy

Project description

RSOME: Robust Stochastic Optimization Made Easy

RSOME (Robust Stochastic Optimization Made Easy) is an open-source Python package for generic modeling optimization problems. Models in RSOME are constructed by variables, constraints, and expressions that are formatted as N-dimensional arrays. These arrays are consistent with the NumPy library in terms of syntax and operations, including broadcasting, indexing, slicing, element-wise operations, and matrix calculation rules, among others. In short, RSOME provides a convenient platform to facilitate developments of optimization models and their applications.

The current version of RSOME supports deterministic, robust optimization and distributionally robust optimization problems. In the default configuration, linear programming problems are solved by the open-source solver linprog() imported from the scipy.optimize package. Interfaces with Gurobi and MOSEK solvers are also provided for solving problems with second-order cone constraints and integer variables.

Introduction

Installing RSOME and solvers

The RSOME package can be installed by using the pip command:


pip install rsome


The current version of RSOME requires the Gurobi or MOSEK solver for solving the formatted models. You may follow these steps to complete Gurobi installation. The MOSEK solver can be installed via steps in this link.

Getting started

In RSOME, models can be specified by using highly readable algebraic expressions that are consistent with NumPy syntax. Below we provide a simple linear program as an example to illustrate the steps of modeling and solving an optimization problem.

from rsome import ro                 # Import the ro modeling tool
from rsome import grb_solver as grb  # Import Gurobi solver interface

model = ro.Model('LP model')         # Create a Model object
x = model.dvar()                     # Define a decision variable x
y = model.dvar()                     # Define a decision variable y

model.max(3*x + 4*y)                 # Maximize the objective function
model.st(2.5*x + y <= 20)            # Specify the 1st constraint
model.st(5*x + 3*y <= 30)            # Specify the 2nd constraint
model.st(x + 2*y <= 16)              # Specify the 3rd constraint
model.st(abs(y) <= 2)                # Specify the 4th constraint

model.solve(grb)                     # Solve the model with Gurobi
Being solved by Gurobi...
Solution status: 2
Running time: 0.0005s

In this sample code, a model object is created by calling the constructor Model() imported from the rsome.ro toolbox. Based on the model object, decision variables x and y are created with the method dvar(). Variables are then used in specifying the objective function and constraints. The last step is to call the solve() method to solve the problem via the imported solver interface grb. Once the solution procedure completes, a message showing the solution status and running time will be printed.

According to the Gurobi solution status, the status code 2 suggests that the problem was solved to optimality (subject to tolerances) and an optimal solution is available. The optimal solution and the corresponding objective value can be obtained by the get() method.

print('x:', x.get())
print('y:', y.get())
print('Objective:', model.get())
x: [4.8]
y: [2.]
Objective: 22.4

The example above shows that RSOME models can be formulated via straightforward and highly readable algebraic expressions, and the formulated model can be transformed into a standard form, which is then solved by the Gurobi (or MOSEK) solver. The basic information of the standard form can be retrieved by calling the do_math() method of the RSOME model object.

formula = model.do_math()
print(formula)
Second order cone program object:
=============================================
Number of variables:          3
Continuous/binaries/integers: 3/0/0
---------------------------------------------
Number of linear constraints: 6
Inequalities/equalities:      6/0
Number of coefficients:       11
---------------------------------------------
Number of SOC constraints:    0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rsome-0.0.6.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

rsome-0.0.6-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file rsome-0.0.6.tar.gz.

File metadata

  • Download URL: rsome-0.0.6.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for rsome-0.0.6.tar.gz
Algorithm Hash digest
SHA256 901e098a5fd6329a8a814fbaceb4d78a5779114c1226604f0cab7600009c2e43
MD5 53c2a80cf2c969c9589aee021afecf97
BLAKE2b-256 38f99c5f92f7f5e5cb44d392ac083bc7f2eae4129f93ed0b9879b142c7a88fbb

See more details on using hashes here.

File details

Details for the file rsome-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: rsome-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for rsome-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d29eed14e7f15fe40505b2f3a764199f6e8513a84bce86e21b3e5e9a6430c402
MD5 4dc0cd6d0472fae3dfceb6fc99289221
BLAKE2b-256 f91e52cda1307e34600d1295bfda34f1b23ff5570b8a544cc84502254ddbb825

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page