Skip to main content

Library for solving optimization problems over Graphs of Convex Sets (GCS).

Project description

GCSOPT

Python library to solve optimization problems in Graphs of Convex Sets (GCS). For a detailed description of the algorithms implemented implemented in this library see the PhD thesis Graphs of Convex Sets with Applications to Optimal Control and Motion Planning . (Please note that the library recently changed name, and in the thesis it is called gcspy.)

Main features

  • Uses the syntax of CVXPY for describing convex sets and convex functions.
  • Provides a simple interface for assembling your graphs.
  • Interface with state-of-the-art solvers via CVXPY.

Installation

You can install the latest release from PyPI:

pip install gcsopt

To install from source:

git clone https://github.com/TobiaMarcucci/gcsopt.git
cd gcsopt
pip install .

Example

Here is a minimal example of how to use gcsopt:

import cvxpy as cp
from gcsopt import GraphOfConvexSets

# Initialize empty directed graph.
G = GraphOfConvexSets(directed=True)

# Add source vertex with circular set.
s = G.add_vertex("s")
xs = s.add_variable(2)
cs = [-2, 0] # Center of the source circle.
s.add_constraint(cp.norm2(xs - cs) <= 1)

# Add target vertex with circular set.
t = G.add_vertex("t")
xt = t.add_variable(2)
ct = [2, 0] # Center of the target circle.
t.add_constraint(cp.norm2(xt - ct) <= 1)

# Add edge from source to target.
e = G.add_edge(s, t)
e.add_cost(cp.sum_squares(xt - xs))

# Solve shortest path problem from source to target.
G.solve_shortest_path(s, t)
print("Problem status:", G.status)
print("Optimal value:", G.value)
print("Optimal solution:")
print("xs =", xs.value)
print("xt =",xt.value)

The otput of this script is:

Problem status: optimal
Optimal value: 4.0
Optimal solution:
xs = [-1.  0.]
xt = [1. 0.]

License

This project is licensed under the MIT License.

Author

Developed and maintained by Tobia Marcucci.

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

gcsopt-0.1.2.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcsopt-0.1.2-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file gcsopt-0.1.2.tar.gz.

File metadata

  • Download URL: gcsopt-0.1.2.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for gcsopt-0.1.2.tar.gz
Algorithm Hash digest
SHA256 72801c51f80115e36cfbe5565fbefdefa9597686f16ba4ec0c02df90b03a9a4b
MD5 a2a0b286728effc31eee48d574ee00f0
BLAKE2b-256 f6c6502deacf9aedd81941f5a20184250a90c68c0518d75eceedacc81a6eabb1

See more details on using hashes here.

File details

Details for the file gcsopt-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gcsopt-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for gcsopt-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bef5d751bbcd540610edfab940f81016580313213d20a7b439c89fa29c28fb24
MD5 076222fd607ba0d4514a4b7c14b11cd6
BLAKE2b-256 16c2809a5f988acf1e99df874c4fe7f40c5709cff11fe47c1da948829734f863

See more details on using hashes here.

Supported by

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