Juan David Baquero Barrios
unread,Oct 3, 2023, 2:33:55 PM10/3/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pyomo Forum
Hi, I hope you can help me to solve this optimization problem:
Is it possible to work pyomo network with multiperiod optimization, I am trying to propose a renewable network with process optimization, however it was not possible for me to define correctly the ports. Is possible to declare it on IDAES?
Firstly I declared a block with certain variables for the whole m.date, afterward (here comes the issue) I am trying to declare an extensive port (because I am splitting the stream later in the problem), but it is not possible for me to define correctly the port, here is the code:
This is what I am doing:
`m.date = Set(initialize=output.index, ordered = True) # is a 120 periods time`
#block of 3 variables:
```
def block_fx_CSP (m,t):
m.area_fxCSP = Var(within = NonNegativeReals, doc = '# area fixed CSP')
m.fxCSP = Var(within = NonNegativeReals, doc = 'Canadian Solar fixed PV (W)')
m.y_fxCSP = Var (domain = Binary)
m.fxCSP_block = Block (m.date, rule = block_fx_CSP)
```
**#1st attempt.** I declared the port as follows but the output is a list of the same first period date variable:
```
for t in m.date:
m.port_fxCSP = Port(m.date, initialize=[(m.fxCSP_block[t].fxCSP, Port.Extensive)])
```
this is the output and it is not correct:
Key : Name : Size : Variable
2019-12-31 19:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 19:00:00].fxCSP
2019-12-31 20:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 19:00:00].fxCSP
2019-12-31 21:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 19:00:00].fxCSP
2019-12-31 22:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 19:00:00].fxCSP
The output should be:
2019-12-31 19:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 19:00:00].fxCSP
2019-12-31 20:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 20:00:00].fxCSP
2019-12-31 21:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 21:00:00].fxCSP
2019-12-31 22:00:00 : fxCSP : 1 : fxCSP_block[2019-12-31 22:00:00].fxCSP
**#2nd attempt:** I declared the port and later the function add, but it replaces all the data therefore the output is a 1 output size port:
```
m.port_fxCSP = Port()
for t in m.date:
m.port_fxCSP.add(m.fxCSP_block[t].fxCSP, Port.Extensive)
```
Output:
port_fxCSP : Size=1, Index=None
Key : Name : Size : Variable
None : <function Port.Extensive at 0x00000165C26A65F0> : 1 : fxCSP_block[2020-01-05 18:00:00].fxCSP
**#3rd attempt:** I declare a function for the port for each m.date as an iterable, however the error indicates not iterable
```
def port_fxCSP (m,t):
return [(m.fxCSP_block[t].fxCSP, Port.Extensive)for t in m.date]
m.fxCSP_port = Port (m.date, initialize=port_fxCSP)
```
TypeError: 'function' object is not iterable
Any suggestions are highly appreciated!