alphaville / optimization-engine

Nonconvex embedded optimization: code generation for fast real-time optimization + ROS support
https://alphaville.github.io/optimization-engine/
Other
512 stars 53 forks source link

Problem about Python Opengen basics #228

Closed Orca-bit closed 3 years ago

Orca-bit commented 3 years ago

When I use the Python code from here, my terminal showed me an error, that is, bounds = og.constraints.CartesianProduct(dim, segment_ids, [ball,rect]) TypeError: __init__() takes 3 positional arguments but 4 were given how can I fix it

alphaville commented 3 years ago

@Orca-bit, thank you for pointing out to this inconsistency. It's actually a mistake in the documentation. In a previous version, the user had to specify the dimension of the Cartesian product set, but we then figured out that this is not necessary.

All you have to do is to construct a CartesianProduct without the dimension, i.e.,

import opengen as og

segment_ids = [1, 4]
dim = 5
ball = og.constraints.Ball2()
rect = og.constraints.Rectangle(xmin=[-1,-2,-3], xmax=[0, 10, -1])
bounds = og.constraints.CartesianProduct(segment_ids, [ball, rect])

I will update the docs tomorrow.