Skip to content

Using external function in nlpsol codegen #3674

Answered by ernestds
LinusTxtonomy asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know exactly what's up with the first errors, but the last one has happened to me and is reproducible as such (3.6.5):

import casadi as ca
import os
import pathlib
import numpy as np
TEMP_FOLDER = pathlib.Path(os.getcwd()) / 'temp'

codegen_folder = TEMP_FOLDER / 'codegen'
codegen_folder.mkdir(exist_ok=True,parents=True)

n = 40
map_size = 20
A = ca.SX.sym('A',n,n)
B = ca.SX.sym('B',n,2)
C = ca.sumsqr(ca.cos(A)@B)

fun = ca.Function('fun_inner',[A,B],[C])
cg = ca.CodeGenerator('fun_inner')
cg.add(fun)
cg.generate(str(codegen_folder) + "/")

os.system(f"""gcc -O3 -march=native -shared {str(codegen_folder / 'fun_inner.c')} -o {str(codegen_folder / ('fun_inner.so'))}""")


fun_inner_…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ernestds
Comment options

@LinusTxtonomy
Comment options

@ernestds
Comment options

Answer selected by LinusTxtonomy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants