Re: [AMPL 11888] Correlation matrix / Risk minimizing objective function

62 views
Skip to first unread message
Message has been deleted

Victor Zverovich

unread,
Apr 27, 2016, 12:48:02 PM4/27/16
to am...@googlegroups.com
Here's an example of a table declaration for reading a two-dimensional parameter amt taken from here:

  table dietAmts IN "ODBC" (ConnectionStr) "Amounts":
    [NUTR, FOOD], amt;

In your case, you'll have the same set twice in the key section, something like [ENERGY_SOURCE, ENERGY_SOURCE], where ENERGY_SOURCE is a set of energy sources such as Coal steam turbine, etc. Since the matrix is symmetric you only need to store half of it.

HTH,
Victor

On Tue, Apr 26, 2016 at 2:39 PM yasmine zakari <yasminez...@gmail.com> wrote:
Hello everyone, 

I have a specific question, and I will deeply appreciate any hint on it. 
I am working on a specific project on AMPL:  I need to implement an objective function that minimizes the risk on the cost for a variable, that has a cost as a parameter and correlation coefficients. The risk is estimated using the variance on cost, and I have my correlation matrix as an input. 
Namely the risk on cost that I want to minimize is on fuel prices ( Fuels types are correlated and coefficients of correlation vary yearly). 

I need to find a way to find an efficient way to enter the correlation matrix in a table ( database on psgAdmin (psql) )  and then use appropriate arguments to read them, and implement them on my objective function. 

The table that I have so far looks like this:
table fuel_prices "inputs/fuel_prices.tab" IN:
[province, fuel, year], fuel_price, cv_fuel_price;
read table fuel_prices;


I can also create maybe another one like thins:


# Table for the correlation coefficients
# table fuel_prices_corr "inputs/fuel_prices_corr.tab"  and IN:
#  [province, year], fuel, correl_coeff1, correl_coeff2;
# read table fuel_prices_corr;

My objective function looks like this:
#### OBJECTIVE ####

# minimize the total cost of power over all study periods and hours, including carbon tax
# pid = project specific id
# a = province
# t = technology
# p = PERIODS, the start of an investment period as well as the date when a power plant starts running.
# h = study hour - unique timepoint considered
# p = investment period
( sum { (pid, a, t, p, h) in PROJECT_VINTAGE_HOURS: dispatchable[t] and t <> 'Compressed_Air_Energy_Storage' } 
DispatchGen[pid, a, t, p, h] * ( variable_o_m_cost_hourly[pid, a, t, p, h] + carbon_cost_per_mwh_hourly[pid, a, t, p, h] + fuel_cost_hourly[pid, a, t, p, h] ) )
My correlation matrix looks like this:
correlation coefficients (%)
2015
Coal steam turbineGas combustion turbineWindCentral PVHydro non pumpedNuclear GenIIINuclear GenIVCoal steam turbine CCS
10.470000.120.121Coal steam turbine
0.4710000.060.060.47Gas combustion turbine
00100000Wind
00010000Central PV
00001000Hydro non pumped
0.120.06000110.12Nuclear GenIII
0.120.06000110.12Nuclear GenIV
10.470000.120.121Coal steam turbine CCS

The values change yearly.



Does anyone have a hint on that please, or a project that uses MPT, and correlated variables? 

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Robert Fourer

unread,
Apr 28, 2016, 11:41:42 AM4/28/16
to am...@googlegroups.com
Can you give an example of (1) the param statement that you want to use in AMPL for the correlation coefficients, and (2) the data file that you want to read to supply values for this param? (It's not clear to me whether this information was in your previous email.)

It may be that the "table" feature, which is intended for pulling data from relational databases, is not well suited to your correlation data, and that instead you should use a "data" statement in conjunction with the AMPL text data format (http://ampl.com/BOOK/CHAPTERS/12-data.pdf) or else AMPL's unformatted "read" command (http://ampl.com/BOOK/CHAPTERS/12-data.pdf#page=21).

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of yasmine zakari
Sent: Wednesday, April 27, 2016 12:27 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 11894] Correlation matrix / Risk minimizing objective function

Thank you very much for your help.
However I still have a problem about the way I can use these coefficients in the objective function. I tried to do this but I can't find a way to implement efficiently the correlation matrix ( that varies yearly) as a table ( I only have raw data).

pid = project specific id ,
a = province,
t = technology ,
p = PERIODS, the start of an investment period as well as the date when a power plant starts running,
h = study hour - unique timepoint considered, and
p = investment period.

set PROJECT_VINTAGE_HOURS := { (pid, a, t, p, h) in AVAILABLE_HOURS: can_build_new[t] };
var DispatchGen {(pid, a, t, p, h) in PROJECT_VINTAGE_HOURS} >= 0;

minimize Variance_Fuel_cost;
+ ( sum { (pid, a, t, p, h) in PROJECT_VINTAGE_HOURS} DispatchGen[pid, a, t, p, h] * DispatchGen[pid, a, t, p, h] * variance_fuel_cost_hourly[pid, a, t, p, h] )
# + 2 * ( sum { t in PROJECT_VINTAGE_HOURS, t2 in PROJECT_VINTAGE_HOURS: t <> t2 }
# DispatchGen[pid, a, t, p, h] * DispatchGen[pid, a, t2, p, h] * covariance_fuel[t,t2]
# * sqrt( cv_fuel_cost[pid, a, t] * fuel_cost_hourly[pid, a, t, p, h] * fuel_cost_hourly[pid, a, t, p, h]) * sqrt( cv_fuel_cost[pid, a , t] * fuel_cost_hourly[pid, a, t2, p, h] * fuel_cost_hourly[pid, a, t2, p, h]) ) )


Message has been deleted

Robert Fourer

unread,
Apr 29, 2016, 5:42:50 PM4/29/16
to am...@googlegroups.com
In general these files look OK. However, readers of this forum do not have the resources to examine them all in detail and figure out what you should do. Do you have a specific question about how to read data from a particular file into a particular AMPL parameter, or how to use a particular AMPL parameter in your objective function or constraints? If so then someone may be able to help you. To increase your chances of getting useful help, you should include with your question only the relevant information, such as the particular AMPL param definition, the data to be read into that param, or the objective definition as you have tried to write it.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of yasmine zakari
Sent: Thursday, April 28, 2016 11:27 AM
To: am...@googlegroups.com
Subject: Re: [AMPL 11899] Correlation matrix / Risk minimizing objective function

I couldn't really apply the resources provided previously.
Please can you take a look at my code (Switch.mod )and the two files that I modify to read the tables.
There is also a file that sums up all the modifications that I made to account to the risk.

Thanks a lot in advance.

switch.mod
​​ get_switch_input_tables_mainland.sh
​​ load.run
​​ modifications_switch


Reply all
Reply to author
Forward
0 new messages