Giter Club home page Giter Club logo

Comments (4)

yoelcortes avatar yoelcortes commented on August 28, 2024

Hi Yalin, I have run into errors when evaluating Monte Carlo. It usually means that the system is not robust (i.e. accumulation of energy/material in streams), or going to an infeasible region (the conversions are too high or something). One problem with using try and exceptions is that information from the last run still lingers and causes a cascade of infeasible scenarios. This could be fixed by resetting all flows each time a system fails. However, if the system is not robust, you could be getting significantly different results for very similar scenarios when you reset flows.

I think you could add the try and except blocks in the <Model>.evaluation method (lines 145, 146) and see what you get:

try: 
    simulate()
except:
    self._system.reset_flows()
    values[i] = [None] * len(funcs)
else:
    values[i] = [i() for i in funcs]

I'd be willing to make this can be an optional behavior in BioSTEAM if you'd like to make a pull request ;)

Alternatively, you could run each sample in the model outside the evaluate method:

for i in samples:
    # Some debugging stuff or, save data
    results_dict = model(i)

If you still can't find where the system is failing I'd be happy to help you out too.

from biosteam.

yalinli2 avatar yalinli2 commented on August 28, 2024

A quick followup that just adding the try/except block won't work (because all flows are set to 0, it leads to divide by 0 error when simulating stream price for TEA). So I think I'll work around this for now. But it's good to know the reset_flows method, would save me a lot of time (I used to restart the kernel every time to de-cache)

However this leads to some additional questions:

  1. When using <Model>.evaluate, does it retain the system's setting on converge_method, maxiter, and molar_tolerance?
  2. If I let my system simulate for five times within the system.py, when executing <Model>.evaluate, for each scenario, will my system be simulated for only once or six times?

Thanks!

from biosteam.

yoelcortes avatar yoelcortes commented on August 28, 2024

Hmm, the streams should have a flow after simulating again... Could one of your products not be updated by simulating the system? As for your numbered questions:

  1. Yes, all settings are kept.
  2. The system is only simulated once in each scenario. If your results are changing significantly after resimulating the system, there may be a problem in one of your units (energy or mass balance). If you send me the files, I can help you debug it.

from biosteam.

yalinli2 avatar yalinli2 commented on August 28, 2024

Thanks for answering my question!

As for the try/except thing, I tried to manually reset my system flows and re-simulate and it worked, so I'm not sure what exactly happened, but I made a couple of changes since that so those might have helped. The unfortunate (or fortunate) thing is that I can run Monte Carlo without getting errors for small trials, so I'll close this for now and maybe revisit when I ran into the problem again, thanks!

from biosteam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.