''' Can you show how to solve a rosenbrock problem with it (in Python)? Toss in a constraint 0 <=x0+x1 <=2 in CasADi ''' import casadi as ca # Define variables x = ca.SX.sym("x", 2) # Define objective function f = (1 - x[0])**2 + 100 * (x[1] - x[0]**2)**2 # Define constraint g = x[0] + x[1] lb = 0 ub = 2 # Define optimization problem nlp = {"x": x, "f": f, "g": g} opts = {"ipopt.print_level": 0} solver = ca.nlpsol("solver", "ipopt", nlp, opts) # Set initial guess x0 = [1, 1] # Solve the problem sol = solver(x0=x0, lbg=lb, ubg=ub) # Print results print("x: ", sol["x"]) print("f: ", sol["f"])