jgillis / fatrop_demo

21 stars 0 forks source link

error:Assertion "(A_ + total).nnz() == total.nnz()" failed #1

Open maozaizhou opened 2 months ago

maozaizhou commented 2 months ago

Hi Joris, I'm running into some issues when trying to use the fatrop solver with the nlpsol interface. The error message I get is: RuntimeError: .../casadi/core/function_internal.cpp:146: Error calling FatropInterface::init for 'solver': .../casadi/interfaces/fatrop/fatropinterface.cpp:377: Assertion "(A + total).nnz() == total.nnz()" failed: HPIPM: specified structure of A does not correspond to what the interface can handle. Structure is: N 102, nx [0, 2, 98, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], nu [0, 243, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0], ng [0, 150, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]. Note that debug_A.mtx and debug_interface.mtx have are written to the current directory when 'debug' option is true. the snippet of the code: is nlp_prob = {'f': self.obj, 'x': vertcat(self.variable), 'g': vertcat(self.constrains)} option = {'debug':True,'structure_detection':'auto'} option["expand"] = True option["fatrop"] = {"mu_init": 0.1} solver = nlpsol('solver', 'fatrop', nlp_prob,option) sol = solver(x0=vertcat(*self.x0), lbx=self.lbx, ubx=self.ubx, ubg=self.ubg, lbg=self.lbg)

What’s weird is that when I use ipopt to solve the same problem with the same constraints, everything works fine. Do you have any idea what might be causing this issue? the original code is: nlp_prob = {'f': self.obj, 'x': vertcat(self.variable), 'g': vertcat(self.constrains)} solver = nlpsol('solver', 'ipopt', nlp_prob) sol = solver(x0=vertcat(*self.x0), lbx=self.lbx, ubx=self.ubx, ubg=self.ubg, lbg=self.lbg)

maozaizhou commented 2 months ago

debug_mtx.zip image

here is the mtx debug info, aprreciate if you could provide some help

ImW1ll commented 2 days ago

Same problem... Did you find any workaround? I get something like this: Error using casadi.Opti/solve (line 562) Error in Opti::solve [OptiNode] at .../casadi/core/optistack.cpp:165: .../casadi/core/function_internal.cpp:147: Error calling FatropInterface::init for 'solver': .../casadi/interfaces/fatrop/fatropinterface.cpp:477: Assertion "errors.empty() && (A + total).nnz() == total.nnz()" failed: HPIPM: specified structure of A does not correspond to what the interface can handle. Structure is: N 2690, nx [10, 10, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1

Error in OptiSetupCar (line 218) sol = opti.solve();

Error in CarOptimization (line 19) OptiSetupCar