Beginner issue: unable to run KNITRO (tried both AMPL and Python)

737 views
Skip to first unread message

Trish Gillett

unread,
Mar 28, 2014, 11:08:26 PM3/28/14
to kni...@googlegroups.com
Hello,

Today I installed KNITRO with a student license, with hopes to use the knitroampl solver for AMPL.

I installed KNITRO to
C:\Program Files (x86)\Ziena\KNITROSTUDENT 9.0.1
and so knitroampl.exe is located at
C:\Program Files (x86)\Ziena\KNITROSTUDENT 9.0.1\knitroampl\knitroampl.exe

First I tried selecting it in AMPL by using
option solver knitroampl;
but when the solve command is called it just prints
Cannot invoke knitroampl: no such program.

Next, following the readme in the knitroampl folder, I tried using the command 
option solver "C:\Program Files (x86)\Ziena\KNITROSTUDENT 9.0.1\knitroampl\knitroampl";
but using this I got a different error:
exit code 3221225781
<BREAK>

I don't know if it was a reasonable thing to try, but I also tried putting a copy of knitroampl.exe in the AMPL folder and again using option solver knitroampl;. Running this also gave the exit code 3221225781.

I read here (link) that I should make sure the KNITRO (knitroampl and lib folders) and AMPL locations are added to the PATH in the System Variables, so I've checked and here's what I see in System Variables:
KNITRODIR: C:\Program Files (x86)\Ziena\KNITROSTUDENT 9.0.1

PATH: %KNITRODIR%\knitroampl;%KNITRODIR%\lib;C:\Users\Trish\Documents\Research\AMPL;<other things>

My AMPL version is: AMPL Student Version 20130906 (MS VC++ 6.0, 32-bit)
My KNITRO is the student version, 32-bit, version number 9.0.1
My OS is Windows 8, 64-bit.
I have rebooted since the installation.

To try and narrow down the problem, I gave KNITRO a shot in Python too.
I ran one of the example .py files, and while importing the knitro package the following error message is produced
Failed to load the KNITRO native library 'knitro.dll'.
Make sure that your environment variables are set properly.

The readme for the Python examples again emphasizes that the 'lib' folder needs to be added to %PATH%, but since I've already verified that (see above) I'm not sure what else I can do to fix this issue.

Any suggestions would be most sincerely appreciated.  Thanks!

Henry Chan

unread,
Mar 29, 2014, 10:30:04 PM3/29/14
to kni...@googlegroups.com
Hi, all,
 
For Windows environment, I normally use the following additional commands to invoke AMPL and KNITRO in the Windows Batch commands file (i.e. BAT file) :
 
cd e:\KNITRO
PATH= e:\ampl
set ZIENA_LICENSE=e:\KNITRO\ziena_license.txt
set solver=knitroampl.exe
ampl
 
Hope that it is useful to solve the AMPL problem and please note that all the AMPL "testing programs" are resting in the Directory "KNITRO".
 
Best regards,
Henry Kar Ming Chan

Trish Gillett

unread,
Mar 30, 2014, 11:47:40 PM3/30/14
to kni...@googlegroups.com
Update: I have a workaround solution.

Since there were only 5 files in the lib folder, I copied and pasted these files into the folder containing the Python code that will import KNITRO.  For example, I put them in the examples/Python/ folder and was able to run those example problems.  In the case of AMPL, I copied and pasted the lib files as well as knitroampl.exe (from the knitroampl folder) into my AMPL main folder and that worked.  I'm still not sure why the system variables aren't working, but this will do the trick for now.

Support Knitro

unread,
Mar 31, 2014, 3:41:03 AM3/31/14
to kni...@googlegroups.com, Support Knitro

Dear Trish,

 

Thank you for the detailed diagnostic you provided. Could you try to go to the knitroampl directory of your KNITRO distribution and try to run

knitroampl testproblem.nl ? This should launch knitroampl on a simple test problem.

 

Moreover, did you use 32 or 64 bits python version in your python test?

 

Best regards

 

 

Manuel RUIZ

Optimization consultant | Consultant en optimisation

 

Artelys FRANCE

12 rue du Quatre-Septembre 75002 PARIS - France

Tel +33 1 44 77 89 00     Fax + 33 1 42 96 22 61

 

Description : Description : email_signature

 

 

De : kni...@googlegroups.com [mailto:kni...@googlegroups.com] De la part de Trish Gillett
Envoyé : samedi 29 mars 2014 04:08
À : kni...@googlegroups.com
Objet : [KNITRO] Beginner issue: unable to run KNITRO (tried both AMPL and Python)

--
You received this message because you are subscribed to "KNITRO Nonlinear Optimization Solver" google group.
To post to this group, send email to KNI...@googlegroups.com
To unsubscribe from this group, send email to KNITRO-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/KNITRO?hl=en
Thank You,
Ziena Optimization, Inc.
www.ZIENA.com
---
You received this message because you are subscribed to the Google Groups "KNITRO Nonlinear Optimization Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knitro+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Support Knitro

unread,
Mar 31, 2014, 8:25:27 AM3/31/14
to Trish Gillett, kni...@googlegroups.com

Dear Trish,

 

Did you reboot your computer after the installation ? Or at least log off from your windows session to force the environment variable to be updated ?

 

Manuel

 

De : kni...@googlegroups.com [mailto:kni...@googlegroups.com] De la part de Trish Gillett
Envoyé : lundi 31 mars 2014 05:48
À : kni...@googlegroups.com
Objet : [KNITRO] Re: Beginner issue: unable to run KNITRO (tried both AMPL and Python)

--

Trish Gillett

unread,
Mar 31, 2014, 1:27:22 PM3/31/14
to kni...@googlegroups.com
Thank you all for the replies!

Henry: Thanks for sharing that trick!  That looks like a good workaround as well.

KNITRO support team: The knitroampl testproblem.nl test runs and solves fine.
I have a 64 bit computer, but my python, AMPL, and KNITRO are all 32 bit.  Could this be part of the problem?
I rebooted after the install.  I also tried changing the KNITRODIR system variable definition by putting quotes around it because it had a space ("C:\Program Files (x86)\Ziena\KNITROSTUDENT 9.0.1"), and I rebooted again after this change.



On Friday, March 28, 2014 11:08:26 PM UTC-4, Trish Gillett wrote:

Sylvain Mouret

unread,
Apr 1, 2014, 10:51:11 AM4/1/14
to kni...@googlegroups.com

Dear Trish,

 

You should not use quotes when defining environment variables in Windows.

In fact, it just will not work.

 

I get that you are able to use KNITRO, but not when the libraries and placed in a location that is not the “current directory”.

Can you try again, without the quote, to run a Python example from the command prompt, and if it does not work, send us the result of the “echo %KNITRODIR%” and “echo %PATH%” commands?

 

Finally, you should be able to run 32-bit applications on your 64-bit operating system with no problem.

Mixing 32-bit/64-bit AMPL and KNITROAMPL is possible as the communication is done through executables and files.

However, when using Python or MATLAB with KNITRO, it is mandatory to use consistent 32-bit/64-bit versions for all tools.

 

Kind regards,

 

Sylvain MOURET

Product Manager

 

Artelys FRANCE

12 rue du Quatre Septembre 75002 Paris FRANCE

Tel +33 1 84 17 59 65  Fax +33 1 42 96 22 61

 

 

De : kni...@googlegroups.com [mailto:kni...@googlegroups.com] De la part de Trish Gillett
Envoyé : lundi 31 mars 2014 19:27


À : kni...@googlegroups.com
Objet : [KNITRO] Re: Beginner issue: unable to run KNITRO (tried both AMPL and Python)

 

Thank you all for the replies!

--

Reply all
Reply to author
Forward
0 new messages