Пример #1
0
from pyomo.opt import SolverFactory
from pyomo.core import AbstractModel
from pyomo.dataportal.DataPortal import DataPortal
from pyomo.environ import *
import pandas as pd
from datetime import datetime

############ Create abstract model ###########
model = AbstractModel()
data = DataPortal()

# ####################Define sets#####################

#Name of all the nodes (primary and secondary substations)
model.N = Set()
data.load(filename='total_nodes.csv', set=model.N)

model.SS = Set()
data.load(filename='nodes.csv', set=model.SS)

#Node corresponding to primary substation
model.PS = Set()
data.load(filename='PS.csv', set=model.PS)

#Allowed connections
model.links = Set(dimen=2)  #in the csv the values must be delimited by commas
data.load(filename='links.csv', set=model.links)

#Nodes are divided into two sets, as suggested in https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Sets.html:
# NodesOut[nodes] gives for each node all nodes that are connected to it via outgoing links
# NodesIn[nodes] gives for each node all nodes that are connected to it via ingoing links
Пример #2
0
from pyomo.opt import SolverFactory
from pyomo.core import AbstractModel
from pyomo.dataportal.DataPortal import DataPortal
from pyomo.environ import *
import pandas as pd
from datetime import datetime
############ Create abstract model ###########
model = AbstractModel()
data = DataPortal()

# ####################Define sets#####################

#Name of all the nodes (primary and secondary substations)
model.N = Set()
data.load(filename='nodes.csv', set=model.N)  #first row is not read

#Allowed connections
model.links = Set(dimen=2)  #in the csv the values must be delimited by commas
data.load(filename='links.csv', set=model.links)

#Nodes are divided into two sets, as suggested in https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Sets.html:
# NodesOut[nodes] gives for each node all nodes that are connected to it via outgoing links
# NodesIn[nodes] gives for each node all nodes that are connected to it via ingoing links


def NodesOut_init(model, node):
    retval = []
    for (i, j) in model.links:
        if i == node:
            retval.append(j)
Пример #3
0
from pyomo.dataportal.DataPortal import DataPortal
from pyomo.environ import *
import pandas as pd
from datetime import datetime
############ Create abstract model ###########
model = AbstractModel()
data = DataPortal()

#Parameter for multi cables analysis
model.Cable_Types = Param()

# ####################Define sets#####################

#Name of all the nodes (primary and secondary substations)
model.N = Set()
data.load(filename='nodes.csv', set=model.N)  #first row is not read

#Node corresponding to primary substation
model.PS = Set(within=model.N)
data.load(filename='PS.csv', set=model.PS)
#Allowed connections
model.links = Set(dimen=2, within=model.N *
                  model.N)  #in the csv the values must be delimited by commas
data.load(filename='links.csv', set=model.links)
#Cable types
model.cable = RangeSet(1, model.Cable_Types)

#Nodes are divided into two sets, as suggested in https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Sets.html:
# NodesOut[nodes] gives for each node all nodes that are connected to it via outgoing links
# NodesIn[nodes] gives for each node all nodes that are connected to it via ingoing links