Error in using APOPT.py solver for Pyomo

673 views
Skip to first unread message

Sandi De La Vega

unread,
Mar 30, 2017, 4:11:46 PM3/30/17
to Pyomo Forum
Hi!

I'm having problems in using the APOPT.py solver. The model works after trying the ipopt however what I need are integer solutions so an MINLP solver should provide more reliable results. 

<model>

from pyomo.opt import SolverFactory

model.pprint()
instance = model.create_instance("nlpver3.dat")
instance.pprint()

opt = SolverFactory("apopt.py")

results = opt.solve(instance,load_solutions=False) #solves and updates instance
results.write()
instance.solutions.load_from(results)
instance.display()

Below is the error I keep on getting.

ApplicationError: Could not execute the command: 'C:\ProgramData\Anaconda2\Library\bin\apopt.py -s c:\users\elliot\appdata\local\temp\tmpxqvhck.pyomo.nl'
Error message: [Error 193] %1 is not a valid Win32 application

I have already followed the instructions provided in the https://github.com/APMonitor/apopt and have already tried using the 32-bit version of Python 2.7 Anaconda. Please help. I appreciate the feedback. Thanks

Laird, Carl Damon

unread,
Mar 30, 2017, 5:13:26 PM3/30/17
to pyomo...@googlegroups.com

Hi Sandi,

 

To me it looks like apopt.py is not executable on its own. You might want to look at the installation instructions for APOPT. Also, you should test what happens if you type “'C:\ProgramData\Anaconda2\Library\bin\apopt.py” in a command prompt. If it doesn’t work there, I suspect it will not work within Pyomo.

 

Regards,

 

Carl.

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sandi De La Vega

unread,
Mar 30, 2017, 11:10:20 PM3/30/17
to Pyomo Forum
Hello, Sir Carl.

    I tried typing 'C:\ProgramData\Anaconda2\Library\bin\apopt.py' in the command prompt and Windows prompted to choose what program I should use to open the apopt.py. I followed the installation instructions listed in the apopt.py file from https://github.com/APMonitor/apopt/blob/master/apopt.py. Below are the instructions: 
Instructions for usage: 1. Place apopt.py in an appropriate folder in the system path (e.g. Linux, /usr/bin/)
So I downloaded the apopt.py and placed it in C:\ProgramData\Anaconda2\Library\bin 2. Set appropriate permissions to make the script executable (e.g. chmod 775 apopt.py) Changed the permissions manually from the apopt.py properties since I'm using Windows 3. In AMPL, Pyomo, or other NL file write, set solver option to apopt.py I specified in my Pyomo script "opt = SolverFactory("apopt.py")" 4. Test installation by running apopt.py -test Using the command prompt, In the directory: C:\ProgramData\Anaconda2\Library\bin typed python apopt.py -test
Here is the screenshot of the result:

If there is another way to install it, please help. Sincerely, Sandi De La Vega

Siirola, John D

unread,
Mar 31, 2017, 12:53:11 AM3/31/17
to pyomo...@googlegroups.com

Sandi,

 

First, this thread is really specific to the APOPT solver and not Pyomo.  You should really direct these questions to the APOPT developers.

 

The APOPT installation instructions look to be Linux/OSX-specific.  For Windows, things are a bit trickier: you cannot (easily) just make python scripts executable.  The solution is to implement an wrapper executable that locates Python and launches it, passing the wrapped script as a command line argument.  There exist examples of doing this scattered across the web.  One possible solution is the following (which I am providing without warranty or really any explanation):

 

1.       Download cli.executable from https://software.sandia.gov/trac/wst/export/HEAD/wst/trunk/admin/packaging/cli.executable into the same directory as the apopt.py script

2.       Rename “cli.executable” to “apopt.exe”

3.       Rename “apopt.py” to “apopt-script.py”

4.       Edit apopt-script.py and add a line at the very top of the file with a single “#” character

5.       Call apopt in Pyomo as ‘opt = SolverFactory(“apopt”)’

 

john

 

From: pyomo...@googlegroups.com [mailto:pyomo...@googlegroups.com] On Behalf Of Sandi De La Vega


Sent: Thursday, March 30, 2017 9:10 PM
To: Pyomo Forum <pyomo...@googlegroups.com>

Subject: [EXTERNAL] Re: Error in using APOPT.py solver for Pyomo

Hello, Sir Carl.

 

    I tried typing 'C:\ProgramData\Anaconda2\Library\bin\apopt.py' in the command prompt and Windows prompted to choose what program I should use to open the apopt.py. I followed the installation instructions listed in the apopt.py file from https://github.com/APMonitor/apopt/blob/master/apopt.py. Below are the instructions: 

Instructions for usage:

1. Place apopt.py in an appropriate folder in the system path (e.g. Linux, /usr/bin/)

So I downloaded the apopt.py and placed it in C:\ProgramData\Anaconda2\Library\bin

2. Set appropriate permissions to make the script executable (e.g. chmod 775 apopt.py)

Changed the permissions manually from the apopt.py properties since I'm using Windows

3. In AMPL, Pyomo, or other NL file write, set solver option to apopt.py

I specified in my Pyomo script "opt = SolverFactory("apopt.py")"

4. Test installation by running apopt.py -test

Using the command prompt,

In the directory: C:\ProgramData\Anaconda2\Library\bin

typed python apopt.py -test

Here is the screenshot of the result:

Image removed by sender.

 

If there is another way to install it, please help.

 

Sincerely,

Sandi De La Vega


On Friday, March 31, 2017 at 4:11:46 AM UTC+8, Sandi De La Vega wrote:

Hi!

 

I'm having problems in using the APOPT.py solver. The model works after trying the ipopt however what I need are integer solutions so an MINLP solver should provide more reliable results. 

 

<model>

 

from pyomo.opt import SolverFactory

 

model.pprint()

instance = model.create_instance("nlpver3.dat")

instance.pprint()

 

opt = SolverFactory("apopt.py")

 

results = opt.solve(instance,load_solutions=False) #solves and updates instance

results.write()

instance.solutions.load_from(results)

instance.display()

 

Below is the error I keep on getting.

 

ApplicationError: Could not execute the command: 'C:\ProgramData\Anaconda2\Library\bin\apopt.py -s c:\users\elliot\appdata\local\temp\tmpxqvhck.pyomo.nl'

        Error message: [Error 193] %1 is not a valid Win32 application

 

I have already followed the instructions provided in the https://github.com/APMonitor/apopt and have already tried using the 32-bit version of Python 2.7 Anaconda. Please help. I appreciate the feedback. Thanks

 

--

Jan Stampfli

unread,
Jun 10, 2019, 9:38:14 AM6/10/19
to Pyomo Forum
Hello, 
I have the same issue. Sadly the cli.executable is no longer available online. Is it possible to make this available again?

Thanks
Jan

To unsubscribe from this group and stop receiving emails from it, send an email to pyomo...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages