salvadorgarciamunoz / kipet

Development repository for Kipet.
GNU General Public License v3.0
20 stars 17 forks source link

AttributeError: module 'kipet' has no attribute 'ReactionModel' #171

Open juanmvenegas opened 3 years ago

juanmvenegas commented 3 years ago

Hello,

I have installed kipet via conda in a Windows 10 machine, but I am having problems in using the package as there seems to a problem importing modules. I attempted to run the

python run_examples.py

command after downloading the examples folder linked in the documentation, but all scripts failed to execute. Upon trying to execute example 1, I get an error message:

r1 = kipet.ReactionModel('reaction-1') AttributeError: module 'kipet' has no attribute 'ReactionModel'

In this same virtual environment I have no problems executing pyomo or other packages, so I am guessing there was a problem with the kipet installation via conda. Are there additional steps to take beyond running the command

conda install -c kwmcbride kipet ?

Thanks for any guidance!

juanmvenegas commented 3 years ago

Update: I was able to successfully run kipet when installing via pip install kipet

It is unclear to me why the conda installation command failed, perhaps the dependencies are marked differently between the two sources?

kwmcbride commented 3 years ago

The Conda version is older and not as up to date as the version hosted on PyPi. The version you installed using pip is most likely version 1.0.6 which is the latest version. The packages for conda have not been updated to the latest version, so they may not work properly at the moment. There was an issue with an included package that caused errors during installation with conda. This dependency has since been removed, but the conda package has not yet been updated. Sorry about this!

I would recommend using a conda environment with KIPET installed using pip. At least for the time being.

In case you are interested, the latest updates to KIPET can be found on my KIPET fork.

juanmvenegas commented 3 years ago

Thank you for the information. I have set up a new environment with a pip installation of kipet. I tried to execute example 1

Ex_1_ode_sim.py

But have run into issues with the ipopt solver. I obtain the following error message:


`Checking expected equation units:

ODE units: A : M/s B : M/s C : M/s

ALG units: rA : M/s rB : M/s

Simulator: Setting up simulation model

TemplateBuilder: Preparing model for simulator

Simulator: Finished creating simulator

ERROR: Solver (ipopt) returned non-zero return code (3221225501) ERROR: Solver log: Ipopt 3.11.1:

**************************************************************************
**** This program contains Ipopt, a library for large-scale nonlinear
optimization.
 Ipopt is released as open source code under the Eclipse Public License
 (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
**************************************************************************
****

NOTE: You are using Ipopt by default with the MUMPS linear solver.
      Other linear solvers might be more efficient (see Ipopt
      documentation).

This is Ipopt version 3.11.1, running with linear solver mumps.

Number of nonzeros in equality constraint Jacobian...:    20024 Number of
nonzeros in inequality constraint Jacobian.:        0 Number of nonzeros
in Lagrangian Hessian.............:        0

Total number of variables............................:     5014
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:     5014 Total
number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du
alpha_pr  ls
   0 0.0000000e+000 2.12e+002 0.00e+000  -1.0 0.00e+000    -  0.00e+000
   0.00e+000   0

Traceback (most recent call last):

File "D:\GoogleDrive\PostUW\PythonLearning\kipet\examples\example_1\Ex_1_ode_sim.py", line 60, in r1.simulate()

File "C:\Users\juanmvenegasPC\anaconda3\envs\kipet4\lib\site-packages\kipet\main_modules\reaction_model.py", line 1292, in simulate self._simulate_core(parameters)

File "C:\Users\juanmvenegasPC\anaconda3\envs\kipet4\lib\site-packages\kipet\main_modules\reaction_model.py", line 1312, in _simulate_core self._run_simulation(parameters)

File "C:\Users\juanmvenegasPC\anaconda3\envs\kipet4\lib\site-packages\kipet\main_modules\reaction_model.py", line 1399, in _run_simulation results = self.simulator.run_sim(**simulator_options)

File "C:\Users\juanmvenegasPC\anaconda3\envs\kipet4\lib\site-packages\kipet\estimator_tools\pyomo_simulator.py", line 412, in run_sim solver_results = opt.solve(self.model, tee=tee, symbolic_solver_labels=True)

File "C:\Users\juanmvenegasPC\anaconda3\envs\kipet4\lib\site-packages\pyomo\opt\base\solvers.py", line 601, in solve raise ApplicationError(

ApplicationError: Solver (ipopt) did not exit normally`


In this new environment, I have successfully executed pyomo scripts uisng the ipopt solver installed. Any suggestions for troubleshooting/debugging this issue would be appreciated! Also not sure if its better to start a new issue for this particular problem.

kwmcbride commented 3 years ago

The problem here is that you are using Mumps. If you have access to the HSL solvers, these are much better at solving the type of problems encountered in KIPET.

juanmvenegas commented 3 years ago

Thank you for the clarification. I will look into compiling ipopt with other solvers.