plasmo-dev / Plasmo.jl

A Platform for Scalable Modeling and Optimization
Other
152 stars 21 forks source link

using setmodel() for edge #9

Closed rimersara closed 4 years ago

rimersara commented 5 years ago

I am trying to use the setmodel() function for an edge that adds an edge to my graph with a specific model for that edge.

Example:

edge1 = Plasmo.add_edge(graph,node_R,node_P)
pipe_model = sspassivelink(pdata_short)
Plasmo.setmodel(edge1, pipe_model)

The setmodel() method seems to work for an older Plasmo version (I believe the Plasmo version 0.2), but it is not working for this current version of Plasmo. Is there a different method I should call for adding a model to an edge?

jalving commented 5 years ago

That's correct, the current version of Plasmo does not support setting models on edges anymore. I decided to make the package more general to facilitate partitioning and decomposition. For now, you will have to use the older version to have that functionality.

I am working on a ModelNetwork object that will provide what you're asking for. I will post here when that is ready.

rimersara commented 5 years ago

Ok. I am using the older version of Plasmo on both Julia 0.5 and Julia 0.7. I seem to be having an issue with PlasmoGraph not working. Do you think this is related to the LightGraphs package/version I have? If so, do you have a recommendation for which LightGraphs version to use on the older Plasmo version?

jalving commented 5 years ago

Can you paste the output you're getting using either version? The older version should work with LightGraphs v0.17 on Julia 0.6.

You can also try checking out branch dev-gasnetwork. That was a branch I split off to keep working with models on edges.

rimersara commented 5 years ago

Ok, so I think I figured out the recent issue why PlasmoGraph was not working -- when I was cloning the Plasmo package from Git, it was not copying the Plasmo.jl file to the lib directory for Julia (I'm working in Julia v0.6).

But, now the issue I am getting is this: ERROR: LoadError: LoadError: invalid redefinition of constant NodeData

I am trying to build a structured type, and I don't know if I am using the correct declarative. For example, I am trying to build a water tank, and have defined it like this:

type NodeData
    time_grid       # Time grid values
    n_supplies      # Number of supply inputs to node
    supply_upper    # Max supply flow rate [cu ft/s]
    n_demands       # Number of demand outputs from node
    pressure_lower  # Pressure min value [psi]
    pressure_upper  # Pressure max value [psi]
    demand_cost     # Objective fn cost of delivering to node
    gen_cost        # Object fn cost of supplying to node
   elevation       # Node elevation [ft]
end

and am getting this error: ERROR: LoadError: LoadError: invalid redefinition of constant NodeData

I've also tried defining it using struct and am getting a similar error. Any advice?

rimersara commented 5 years ago

Nevermind. I figured it out. I am using workspace() to clear the cache of variables before running everything again. Now it works.

jalving commented 5 years ago

It's very possible that NodeData is a type defined somewhere in a file you are including. You could try calling it something else and see if that works as well.

I'll leave this issue open until I get the network functionality working with the latest version.

rimersara commented 5 years ago

I think the issue is that I ran one of the gas network examples prior to the water network one I am running. And both of them have a NodeData defined differently. So I needed to clear the gas network one before running the water network one. Like I said, the workspace() seems to have fixed it.

But thank you for your help on this! Just learning Julia now, so trying to get acquainted with the language itself, its different versions, and its dependencies. But it seems to be working now! So thanks!

jalving commented 4 years ago

Closing this issue for now. Network structures with edge models was an old abstraction that was abandoned in favor of a more pure graph abstraction. The network abstraction might get revisited in the future.