Comments (1)
Even simpler example:
import casadi as ca
x = ca.MX.sym("x",1)
p = ca.MX.sym("p",1)
g = -x
print(ca.detect_simple_bounds(x,p,g,ca.MX([-2]),ca.MX([-2])))
g = x
print(ca.detect_simple_bounds(x,p,g,ca.MX([-2]),ca.MX([-2])))
Half assed hacky fix?
x = ca.MX.sym("x",2)
p = ca.MX.sym("p",2)
lbg = ca.MX([-2, -2])
ubg = ca.MX([2, -1])
g = p[0] * x + p[1]
[gi,lbx,ubx,lam_f,lam_b] = ca.detect_simple_bounds(x,p,g,lbg,ubg)
dx = 1.
simple_bounds_idx = list(set(range(g.numel())) - set(gi))
f_g = ca.Function('x',[x,p], [g[simple_bounds_idx]],)
f_lbg = ca.Function('x',[x,p], [lbg[simple_bounds_idx]],)
f_ubg = ca.Function('x',[x,p], [ubg[simple_bounds_idx]],)
constant = f_g(0,p)
coeff = (f_g(dx,p) - constant)/dx
lbg = f_lbg(0,p)
ubg = f_ubg(0,p)
lbx_f = ca.Function('lbx',[p],[ca.if_else(coeff >= 0, (lbg - constant)/coeff,(ubg - constant)/coeff)])
ubx_f = ca.Function('ubx',[p],[ca.if_else(coeff >= 0, (ubg - constant)/coeff,(lbg - constant)/coeff)])
p0 = [-1,2]
print(lbx_f(p0))
print(ubx_f(p0))
p0 = [1,2]
print(lbx_f(p0))
print(ubx_f(p0))
from casadi.
Related Issues (20)
- Refactor handling of event dynamics in DaeBuilder
- Mapping with openmp segmentation faults sometimes
- Run-time warnings
- Linear system of equations with Casadi: A\b HOT 1
- Event support in integrator class
- Building Casadi with ipopt HOT 2
- Run `autoconf` HOT 1
- using Casadi HOT 1
- Can I use the casadi::MX type in a logical conditions in an if-else statement?
- octave segfaults, at least 3.6.0
- finish daqp
- fix test_jit_serialize on mac
- libcasadi_interpolant_linear.dll not found HOT 1
- Difference between work vector size in generated header and c files HOT 1
- Set `MACOSX_DEPLOYMENT_TARGET` to 11.0 for CasADi v3.6.5 on arm64 macOS – `libcasadi.3.7.dylib` requires 11.1 and breaks linkage HOT 1
- Using casadi+integrator in a different thread
- compact dense sparsity patterns HOT 3
- Symmetric jacobian with MX
- pseudo MX optimizations
- Add inlining MX call to SXFunction HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casadi.