Coder Social home page Coder Social logo

Comments (5)

korken89 avatar korken89 commented on May 19, 2024

You seem to have used the released version of OpEn to build the development version. Please wait a day or so and we will release the new version, or do the following to install the development version:

  1. sudo pip3 uninstall opengen
  2. cd open-codegen
  3. sudo pip3 install .

Here is a reference python file (you also seem to have missed the \ in the code), tested with commit 64977f4:

import casadi.casadi as cs
import opengen as og

u = cs.SX.sym("u", 5) # decision variable (nu = 5)
p = cs.SX.sym("p", 2) # parameter (np = 2)
phi = og.functions.rosenbrock(u, p) # cost function

bounds = og.constraints.Ball2(None, 1.5) # ball centered at origin

problem = og.builder.Problem(u, p, phi).with_constraints(bounds)

meta = og.config.OptimizerMeta() \
    .with_version("0.0.0") \
    .with_authors(["P. Sopasakis", "E. Fresk"]) \
    .with_licence("CC4.0-By") \
    .with_optimizer_name("the_optimizer")

build_config = og.config.BuildConfiguration() \
    .with_build_directory("python_build") \
    .with_build_mode("debug")

solver_config = og.config.SolverConfiguration() \
    .with_lfbgs_memory(15) \
    .with_tolerance(1e-5) \
    .with_max_inner_iterations(155)

builder = og.builder.OpEnOptimizerBuilder(problem,
    metadata=meta,
    build_configuration=build_config,
    solver_configuration=solver_config)
builder.enable_tcp_interface()
builder.build()

mng = og.tcp.OptimizerTcpManager('python_build/the_optimizer')
mng.start()

pong = mng.ping() # check if the server is alive
print(pong)
solution = mng.call([1.0, 50.0]) # call the solver over TCP
print(solution)

mng.kill()

from optimization-engine.

alphaville avatar alphaville commented on May 19, 2024

Hi @sinashm. Can you please provide your system information as in the bug template? Which version of opengen are you using? Did you download it using pip install opengen? What OS are you using?

I think that the error you're getting says that the code has been generated, but rust cannot compile it. In order to get a better understanding of the error, can you go inside the auto-generated folder (that is, python_build/the_optimizer) and run the following command:

cargo build

As a side note, indentations are important in Python. Can you double-check that you have copied the example code properly?

from optimization-engine.

sinashm avatar sinashm commented on May 19, 2024

Hi @alphaville,

I am running Ubuntu 16.04, Python 2.7.12 and I used sudo pip install opengen for installation. The version of opengen is opengen-0.0.7

The output of cargo build is:

sina:the_optimizer$ cargo build
   Compiling serde_json v1.0.39
   Compiling icasadi v0.2.1 (/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/icasadi)
error: failed to run custom build command for `icasadi v0.2.1 (/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/icasadi)`
process didn't exit successfully: `/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-ed0abb2625a5001c/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "src" "-Wall" "-Wextra" "-Wall" "-Wpedantic" "-Wno-long-long" "-Wno-unused-parameter" "-o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_cost.o" "-c" "extern/auto_casadi_cost.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "src" "-Wall" "-Wextra" "-Wall" "-Wpedantic" "-Wno-long-long" "-Wno-unused-parameter" "-o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_grad.o" "-c" "extern/auto_casadi_grad.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "src" "-Wall" "-Wextra" "-Wall" "-Wpedantic" "-Wno-long-long" "-Wno-unused-parameter" "-o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_constraints_type_penalty.o" "-c" "extern/auto_casadi_constraints_type_penalty.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "src" "-Wall" "-Wextra" "-Wall" "-Wpedantic" "-Wno-long-long" "-Wno-unused-parameter" "-o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/icasadi.o" "-c" "extern/icasadi.c"
exit code: 0
AR_x86_64-unknown-linux-gnu = None
AR_x86_64_unknown_linux_gnu = None
HOST_AR = None
AR = None
running: "ar" "crs" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/libicasadi.a" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_cost.o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_grad.o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/auto_casadi_constraints_type_penalty.o" "/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out/extern/icasadi.o"
exit code: 0
cargo:rustc-link-lib=static=icasadi
cargo:rustc-link-search=native=/home/sina/work_spaces/codes/Python_OpEn/python_build/the_optimizer/target/debug/build/icasadi-be6cc7b01cf3f3b0/out

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'libclang.so\', \'libclang-*.so\', \'libclang.so.*\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

I tried the code that Emil shared above and got same error.

from optimization-engine.

sinashm avatar sinashm commented on May 19, 2024

You seem to have used the released version of OpEn to build the development version. Please wait a day or so and we will release the new version, or do the following to install the development version:

1. `sudo pip3 uninstall opengen`

2. `cd open-codegen`

3. `sudo pip3 install .`

Here is a reference python file (you also seem to have missed the \ in the code), tested with commit 64977f4:

import casadi.casadi as cs
import opengen as og

u = cs.SX.sym("u", 5) # decision variable (nu = 5)
p = cs.SX.sym("p", 2) # parameter (np = 2)
phi = og.functions.rosenbrock(u, p) # cost function

bounds = og.constraints.Ball2(None, 1.5) # ball centered at origin

problem = og.builder.Problem(u, p, phi).with_constraints(bounds)

meta = og.config.OptimizerMeta() \
    .with_version("0.0.0") \
    .with_authors(["P. Sopasakis", "E. Fresk"]) \
    .with_licence("CC4.0-By") \
    .with_optimizer_name("the_optimizer")

build_config = og.config.BuildConfiguration() \
    .with_build_directory("python_build") \
    .with_build_mode("debug")

solver_config = og.config.SolverConfiguration() \
    .with_lfbgs_memory(15) \
    .with_tolerance(1e-5) \
    .with_max_inner_iterations(155)

builder = og.builder.OpEnOptimizerBuilder(problem,
    metadata=meta,
    build_configuration=build_config,
    solver_configuration=solver_config)
builder.enable_tcp_interface()
builder.build()

mng = og.tcp.OptimizerTcpManager('python_build/the_optimizer')
mng.start()

pong = mng.ping() # check if the server is alive
print(pong)
solution = mng.call([1.0, 50.0]) # call the solver over TCP
print(solution)

mng.kill()

@korken89 I followed your steps and it seems working,
I am getting a solution.

DEBUG:root:Sending request to TCP/IP server
{u'exit_status': u'Converged', u'max_constraint_violation': 0.0, u'num_outer_iterations': 1, u'solution': [0.9064781646490043, 0.8254860578824491, 0.6864387632940303, 0.475070417629115, 0.22354094609769304], u'last_problem_norm_fpr': 6.928368508833967e-06, u'solve_time_ms': 2.332177, u'num_inner_iterations': 28}
INFO:root:Killing server

from optimization-engine.

alphaville avatar alphaville commented on May 19, 2024

@korken89 @sinashm This is still strange because we had tested the released version of opengen on Ubuntu and it links to the previously released version of OpEn in Rust (0.4.0), so it should have worked. In any case, I think we can close this issue.

from optimization-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.