pjamesjoyce / lcopt

Create foreground LCA models via an intuitive user interface and analyse them using Brightway2
BSD 3-Clause "New" or "Revised" License
22 stars 6 forks source link

Run lcopt from any brightway project #38

Open haasad opened 6 years ago

haasad commented 6 years ago

Maybe I'm missing something, but now that you made lcopt work nicely with all ecoinvent versions it should be possible to run lcopt from any project. Something along those lines (simplified):

if not search_index:
    write_search_index()
model = LcoptModel('test')
model.launch_interact()

You would probably need a check in the write_search_index-function that there is actually a valid ecoinvent/forwast db in the project. (Several ecoinvent dbs in the same project could also make this a bit more complicated)

If this is possible, it would also help with #37, because you wouldn't need to copy the background db for every model. Instead all models would be stored alongside each other in the same project where they were created. The lcopt_bw2_setup-function and its corresponding LCOPT_Setup-project would then only be required for people without a previous brightway installation.

pjamesjoyce commented 6 years ago

Hi @haasad, lcopt writes foreground models in a particular way (it was originally designed to create a specific type of foreground model, brightway integration came later).

There is a way to convert existing brightway projects (saved as bw2package files) into lcopt format - here's the notebook that explains it. The key function is create_LcoptModel_from_BW2Package() - Note: it needs updating to work with ecoinvent versions other than 3.3 cutoff.

In theory you could generate an lcopt model from any brightway project, but it would become a separate thing. I'm guessing you want to use lcopt to view and update existing brightway projects in situ as an extension to the activity browser. This might be possible by adding tags to the existing activities (e.g. the lcopt_type tag).

I'll look into it...

haasad commented 6 years ago

As you correctly guessed, this idea comes from trying to improve the compatibility of lcopt and the AB. I think it would be very neat to have the option to launch lcopt in any given project and add a foreground model via the lcopt interface. Importing an existing foreground model to lcopt would be nice to have, but only secondary priority here.

But probably I'm thinking too strongly from the direction of brightway and the AB, I can see that this is not a high priority for lcopt itself.

cardosan commented 6 years ago

+1 for this IMO this would start to make the AB/lcopt suite very interesting having both very nice and complementary features. Typical case: one might need to search and modify a process (for which AB is the way to go) and use this to build his parametrized model (obviously in lcopt).