What could be the cause of "ERROR: Unexpected exception while running model: 31704179198" in pyomo? - pyomo

I get this error message whenever I try to run code that uses the .dae extension.
I've been getting this error on code for a problem I've been working on. Eventually, I ran code that I found online for a different problem and got the same error. This makes me think that it's some error with how I'm running the solver (ipopt) rather than the code itself
Here's a link to the code from GitHub that I'm getting an error message with: https://github.com/Pyomo/pyomo/blob/master/examples/dae/Optimal_Control.py
I've been evoking the solve with:
pyomo solve --solver=ipopt filename.py

Most of the DAE examples come with a second Python script for running the model. Models formulated with Pyomo.DAE are meant to be run from Python scripts and not using the pyomo solve command line. The optimal control problem you're looking at can be solved by using the command
python run_Optimal_Control.py
If you take a look at this file you'll see the syntax for applying a discretization scheme to the dynamic model, creating a solver object using the SolverFactory, solving the model, and plotting the results.

Related

Why does pm4py.view doesn't generate any image

For a business process discovery task, I am trying to generate a process model, following pm4py python library. Here's a sample code:
!pip install pm4py
import pm4py
log = pm4py.read_xes('/content/running-example.xes')
process_model, initial_marking, final_marking = pm4py.discover_petri_net_inductive(log)
pm4py.view_petri_net(process_model, initial_marking, final_marking, format="svg")
However, I get output as:
parsing log, completed traces :: 100%
6/6 [00:00<00:00, 121.77it/s]
But no image as is expected from the website: https://pm4py.fit.fraunhofer.de/getting-started-page#discovery
Being relatively new to the world of python, what I learnt from other coders' suggestions here on SO that always read in depth the source code in case of open source libraries.
Here is pm4py visual links:
https://github.com/pm4py/pm4py-core/blob/afee8b0932283b8f8f02dd2b6cc0968a1f1cc723/pm4py/visualization/process_tree/visualizer.py#L69
and specifically for my example:
https://github.com/pm4py/pm4py-core/blob/afee8b0932283b8f8f02dd2b6cc0968a1f1cc723/pm4py/vis.py#L17
But I am not able to figure out how to manipulate it.
Can someone please point out the problem to me and help me generate the views. Also, if anyone has done business process generations before, maybe if you could suggest me any libraries or techniques to analyse event-logs data it would be really helpful.
to visualize the process models mined in PM4Py, make sure that you have graphviz installed on your computer.
see https://pm4py.fit.fraunhofer.de/install for more information on this.

Code conversion from python 2 to python 3

I'm setting up a new algorithm which combines an object detector(bounding box detector) which is in python 3 and a mask generator which is in python 2. The problem here is I have several python 2 files which is required for the mask generation algorithm. So I tried 2to3 to convert all my python 2 files to python 3. The script seemed like working but as it was a deep learning algorithm(for mask generation when bounding box coordinates are given as input) which needs some pytorch weights to be loaded, while testing the model in python 3 the program was throwing out error like
"RuntimeError: Expected object of type torch.FloatTensor but found
type torch.cuda.FloatTensor for argument #2 ‘weight’"
I have searched in PyTorch forums but none of the posts were useful to me. Is it because my mask generation code is trained in python 2 ?
Does that means while loading the weights and testing the model I should use python 2 not python 3 ? It would be great if someone can shed some light on this. As a work around I can still use the object detector code downgraded to python 2. But still I want to know why it was throwing the error.
The problem is(can) that cpu object is expected but it gpu object. Try to put the object to cpu:
mask.cpu()
I just resolved the issue by re-installing the torch(0.4.0) and torchvision(0.2.1) for my conda environment. I had to downgrade the versions of both of them. Finally I was successful in converting my python 2.7 code to python 3. Thanks to 2to3 library. Actually this error was happening in the image normalize function of the PyTorch. That was an internal function which accepts the image array as tensors.
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: expected type torch.cuda.FloatTensor but got torch.FloatTensor

I want to display saxon errors in python

I am using saxon xslt processor and python script to perform xslt transformations. I want to add exception handling to the python script. The saxon processor has inbuilt exceptions which are raised with codes (eg., SXXP003) etc. These error messages are displayed in the console because i am executing saxon files using batch file. The issue is that the saxon errors are not being written to traceback stack in python because of which i am unable to retrieve the error message. please provide a solution for the problem. I want to display the saxon error in the try except of python.
Regards
Anshul Mittal
Python has a number of different ways of invoking external programs via their command line interface: check whether the method you are using has any way of redirecting the System.err output stream. (I don't know Python so I can't advise on that aspect). If you can find a way to do this, then you can try to parse the error messages and extract the error codes.
A different approach, which might perform better and would give you more control (but which might involve more effort to configure correctly), would be to use the new Saxon/C product and invoke it via its C APIs, instead of invoking the Java product via its command-line interface.
In addition to Mike's reply, a python interface for Saxon/C is in development and worth a look:
https://github.com/ajelenak/pysaxon

troubleshooting cascalog

i am a new Clojure/Cascalog user trying to migrate some pig scripts, but often i get an error like the following in repl.
FlowException local step failed cascading.flow.planner.FlowStepJob.blockOnJob (FlowStepJob.java:191)
"with-debug" gives some more information but still no root cause of the issue. Any ideas on how to improve this?
I agree that the stacktraces are sometimes very unhelpful. One thing I can suggest is writing unit tests: http://sritchie.github.com/2011/09/30/testing-cascalog-with-midje.html which narrows down significantly where your actual problem lies.
If your query works for basic cases but fails on big data you can add a trap, to see what inputs are causing a failure:
(<- .... (:trap (hfs-textline "s3://.../errors" :sinkmode :replace)))

Apps with label XYZ could not be found

today I ran into an error and have no clue how to fix it.
Error: App with label XYZ could not be found. Are you sure your INSTALLED_APPS setting is correct?
Where XYZ stands for the app-name that I am trying to reset. This error shows up every time I try to reset it (manage.py reset XYZ). Show all the sql code works.
Even manage.py validate shows no error.
I already commented out every single line of code in the models.py that I touched the last three months. (function by function, model by model) And even if there are no models left I get this error.
Here http://code.djangoproject.com/ticket/10706 I found a bugreport about this error. I also applied one the patches to allocate the error, it raises an exception so you have a trace back, but even there is no sign in what of my files the error occurred.
I don't want to paste my code right now, because it is nearly 1000 lines of code in the file I edited the most.
If someone of you had the same error please tell me were I can look for the problem. In that case I can post the important part of the source. Otherwise it would be too much at once.
Thank you for helping!!!
I had a similar problem, but I only had it working after creating an empty models.py file.
I was running Django 1.3
Try to clean up all your build artifacts: build files, temporary files and so on. Also ./manage.py test XYZ will show you stack trace. Later try to run python with -m pdb option and step through the code to see where you fail and why.
You don't specify which server you're using. With Apache you'll almost certainly need a restart for things to take effect. If you're using the development one try restarting that. If this doesn't work you may need to give us some more details.
I'd also check your paths as you may have edited one file but you may be using a different one.
Plus check what's still in your database, as some of your previous versions may be interfering.
Finally as a last resort I'd try a clean install (on another django instance) and see if that goes cleanly, if it does then I'd know that I'd got a conflict, if not then the problem's in the code.