Re: [AMPL 24720] How Hooking my Solver to AMPL ?

A quick question – I am using the free (community) edition of AMPL (Linux version 20230124 – so the January 2023 version)… I have developed a new solver, but unable to hook it to AMPL… I have followed the instructions in Section One of David Gay’s manual “Hooking Your Solver to AMPL” (the 2017 version), and I was able to create an executable for my solver… However, when I tried to hook it to AMPL, it doesn’t work – it says “Error at _cmdno 2 executing “solve” command; can’t open /tmp/at4895.sol”… Are there any known issues about hooking solvers to the free edition of AMPL?

(I first created “amplsolver.a” as described at netlib/ampl/solvers and went from there.)


When “solve” was executed, AMPL wrote the problem to a temporary file /tmp/ that was read by the AMPL interface to your solver. Then after your solver finished working, the AMPL interface should have written the solution to a temporary file /tmp/at4895.sol that would be read by AMPL.

The “Error at _cmdno 2 executing “solve” command; can’t open /tmp/at4895.sol” usually appears because /tmp/at4895.sol was not written. Documentation of the procedures for writing this file is given in Writing the stub.sol file which starts on page 18 of Hooking Your Solver to AMPL.

The most common reasons for this error are:

  • The AMPL-solver interface is not calling the function write_sol, which writes the .sol file; or write_sol is not being called correctly.
  • The write_sol fucntion is trying to write the .sol file to a folder/directory where the solver process does not have the necessary permissions.
1 Like