Hello all, My goal is this: 1) Solve an NLP once. 2) Capture the solver's solution (.sol file) 3) Use the solution to initialize the NLP in a different instance. (I know AMPL keeps the current solution and uses it as an initial guess for the next solve, but in my case, I am iterating between AMPL and another program.) The approach I have taken: 1) Write a solver wrapper; we'll call it 'asolver'. asolver is a shell- like script that calls the ACTUAL solver and copies it's .sol file to the current directory. e.g. sample listing for asolver #!/bin/sh ipopt -s $1 cp $1 currsoln.sol 2) Solve the NLP once, appending "option solver asolver" before the "solve" statement. 3) In the next NLP instance, I append "solution currsoln.sol" before the "solve" statement, hoping that the initial guess of the primal and dual variables in the NLP will be set to the values in currsoln.sol. Unfortunately, I get the following error: AMPL Version 20060626 (Linux 2.4.21-4.EL) b9 10 2 0 8815 20060626 0 4 0 373 # problem at26413 8815 8815 1 118 8515 # vars, constraints, objectives, ranges, eqns 2640 0 # nonlinear constraints, objectives 0 0 # network constraints: nonlinear, linear 3957 0 0 # nonlinear vars in constraints, objectives, both 0 0 1 1 # linear network variables; functions; arith, flags 0 0 0 0 0 # discrete variables: binary, integer, nonlinear (b,c,o) 26630 5 # nonzeros in Jacobian, gradients 0 0 # max name lengths: constraints, variables 0 540 0 1135 0 # common exprs: b,c,o,c1,o1 .....[high ASCII garbage stripped]..... bad line in currsoln.sol: --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
Oops, I accidentally pressed "Send" before finishing the previous email. Anyhow, I was just wondering: 1) Is this the proper way for obtaining a .sol file? Is my approach reasonable? 2) If it is, what am I doing wrong? In theory, the "solution filename" statement ought to work. Thanks for your help! David On Feb 12, 2:14 pm, David Veerasingam <[hidden email]> wrote: > Hello all, > > My goal is this: > 1) Solve an NLP once. > 2) Capture the solver's solution (.sol file) > 3) Use the solution to initialize the NLP in a different instance. (I > know AMPL keeps the current solution and uses it as an initial guess > for the next solve, but in my case, I am iterating between AMPL and > another program.) > > The approach I have taken: > 1) Write a solver wrapper; we'll call it 'asolver'. asolver is a shell- > like script that calls the ACTUAL solver and copies it's .sol file to > the current directory. > > e.g. sample listing for asolver > #!/bin/sh > ipopt -s $1 > cp $1 currsoln.sol > > 2) Solve the NLP once, appending "option solver asolver" before the > "solve" statement. > 3) In the next NLP instance, I append "solution currsoln.sol" before > the "solve" statement, hoping that the initial guess of the primal and > dual variables in the NLP will be set to the values in currsoln.sol. > > Unfortunately, I get the following error: > > AMPL Version 20060626 (Linux 2.4.21-4.EL) > b9 10 2 0 8815 20060626 0 4 0 373 # problem at26413 > 8815 8815 1 118 8515 # vars, constraints, objectives, ranges, eqns > 2640 0 # nonlinear constraints, objectives > 0 0 # network constraints: nonlinear, linear > 3957 0 0 # nonlinear vars in constraints, objectives, both > 0 0 1 1 # linear network variables; functions; arith, flags > 0 0 0 0 0 # discrete variables: binary, integer, nonlinear > (b,c,o) > 26630 5 # nonzeros in Jacobian, gradients > 0 0 # max name lengths: constraints, variables > 0 540 0 1135 0 # common exprs: b,c,o,c1,o1 > .....[high ASCII garbage stripped]..... > bad line in currsoln.sol: You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
Sorry, I've found the solution. The proper way to write a .sol file is to use the "write" command. I was under the impression that the write command only wrote ".nl" files, but I forgot that when an .nl file is explicitly written, the .sol file also appears (without it being deleted by AMPL). Using the "solution" command on a .sol generated in this fashion seems to work okay. David On Feb 12, 2:16 pm, David Veerasingam <[hidden email]> wrote: > Oops, I accidentally pressed "Send" before finishing the previous > email. > > Anyhow, I was just wondering: > 1) Is this the proper way for obtaining a .sol file? Is my approach > reasonable? > 2) If it is, what am I doing wrong? In theory, the "solution filename" > statement ought to work. > > Thanks for your help! > > David > > On Feb 12, 2:14 pm, David Veerasingam <[hidden email]> wrote: > > > Hello all, > > > My goal is this: > > 1) Solve an NLP once. > > 2) Capture the solver's solution (.sol file) > > 3) Use the solution to initialize the NLP in a different instance. (I > > know AMPL keeps the current solution and uses it as an initial guess > > for the next solve, but in my case, I am iterating between AMPL and > > another program.) > > > The approach I have taken: > > 1) Write a solver wrapper; we'll call it 'asolver'. asolver is a shell- > > like script that calls the ACTUAL solver and copies it's .sol file to > > the current directory. > > > e.g. sample listing for asolver > > #!/bin/sh > > ipopt -s $1 > > cp $1 currsoln.sol > > > 2) Solve the NLP once, appending "option solver asolver" before the > > "solve" statement. > > 3) In the next NLP instance, I append "solution currsoln.sol" before > > the "solve" statement, hoping that the initial guess of the primal and > > dual variables in the NLP will be set to the values in currsoln.sol. > > > Unfortunately, I get the following error: > > > AMPL Version 20060626 (Linux 2.4.21-4.EL) > > b9 10 2 0 8815 20060626 0 4 0 373 # problem at26413 > > 8815 8815 1 118 8515 # vars, constraints, objectives, ranges, eqns > > 2640 0 # nonlinear constraints, objectives > > 0 0 # network constraints: nonlinear, linear > > 3957 0 0 # nonlinear vars in constraints, objectives, both > > 0 0 1 1 # linear network variables; functions; arith, flags > > 0 0 0 0 0 # discrete variables: binary, integer, nonlinear > > (b,c,o) > > 26630 5 # nonzeros in Jacobian, gradients > > 0 0 # max name lengths: constraints, variables > > 0 540 0 1135 0 # common exprs: b,c,o,c1,o1 > > .....[high ASCII garbage stripped]..... > > bad line in currsoln.sol: You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
Free forum by Nabble | Edit this page |