This isnt working for me, no matter which Optimizer I use.
Writing to .lp or .mps files is fine, but those are rejected by AMPL solvers. Where writing to .nl files results in weird formatting (that causes parse errors when I try to feed it to a solver.)
This is what my .nl file looks like, when I generate it with JuMP.write_to_file(model, "pentomino.nl")
I use AmplNLWriter with Bonmin_jll and it printed the same .nl file as when I just use HiGHS.Optimizer (without AmplNLWriter). I exported the model “normally” with JuMP.write_to_file(model, nl_path) - but when trying to load this file into AMPL in python (which supposedly accepts .nl files) with ampl.read(nl_filename), it threw a parse error. (The .nl file looks like it’s missing spaces or something, I’m not sure, I’ve never used this format before.)
I’ll try and prepare a minimal reproducible example, sure, since my codes are like 300+ lines long atm. Thank you for your interest in helping !
It’s also possible that ampl simply doesn’t accept .nl files at all? I know it prefers its own .mod and .dat files, but those are not trivial to generate with JuMP - I have to generate them manually from Julia by printing strings, which is kind of annoying (and error prone).
Edit: worth mentioning, my problem is linear. So I want to use specialized NL solvers like CPLEX and stuff, not Bonmin and those ones.
Thanks for the help in DMs, seems that AMPL’s Python API doesn’t support the .nl file format at all, that’s where the problem lies.
To anwser why not CPLEX directly: I have an AMPL license which provides online CPLEX solving, but don’t have a CPLEX license personally, and my model is much too big for the free version (1000x1000 max), that’s why I used AMPL - and I was told it would read .nl files, not just .mod and .dat files, which was my mistake! Problem closed