[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-glpk] Conversion of AMPL model defect #2
From: |
Harley Mackenzie |
Subject: |
[Help-glpk] Conversion of AMPL model defect #2 |
Date: |
Tue, 07 Aug 2012 20:44:50 +1000 |
Sorry if this is duplicated, but had to resend as I sent it from my work
account and the GLPK list blocks my email and requires it to be
moderated.
This is a model data error and the AMPL code looks reasonable but I keep
getting an empty result set.
Here is the AMPL code:
param effective_MDQ {t in DAYS, Cid in SUPPLY_CONTRACTS} =
max {(p,Cid) in DAILY_CONTRACT_PARAMETERS : P2[p] = 1}
daily_contract_data[t,Cid,p];
I have cut the original problem down to the essentials in the GLPK
script below but it is still reasonably complex. The parameter
"effective_MDQ" is meant to be calculated as the maximum of the selected
parameters for each day and each contract but returns empty content.
The print statement:
printf {t in DAYS, (p, Cid) in {(p,Cid) in DAILY_CONTRACT_PARAMETERS :
P2[p] = 1}}
"%d %s %s %4d\n", t, Cid, p, daily_contract_data[t,Cid,p];
does print out the expected result in the script, but the max() function
in the calculation of the "effective_MDQ" parameter doesnt seem to
calculate the maximum and I cant work out how to write the statement to
see what elements are being considered for the max() function.
The test script prints out the important variables and the final value
of the "effective_MDQ" parameter that is empty.
Regards,
Harley
-----
set DAYS;
param date {DAYS};
param v1 {DAYS};
param v2 {DAYS};
set CONTRACTS; ## set of contract IDs
set PARAMETERS; ## set of parameters found in contracts
param parameter_period {PARAMETERS} symbolic in {"Day", "Month", "Year",
"NA"};
param P1 {PARAMETERS} binary;
param P2 {PARAMETERS} binary;
param P3 {PARAMETERS} binary;
param contract_parameter {PARAMETERS,CONTRACTS} symbolic in
{"supply","swap","storage","transport","NA","day","month","year","Yes","No"};
# Subsets of Contracts: Type of Contracts
set ACTIVE_CONTRACTS within CONTRACTS :=
{Cid in CONTRACTS : contract_parameter["C_Active",Cid] = "Yes"};
set SUPPLY_CONTRACTS within ACTIVE_CONTRACTS :=
{Cid in ACTIVE_CONTRACTS : contract_parameter["Ctype",Cid] =
"supply"};
# Subsets: Daily Contract Parameters Used in Contracts
set DAILY_CONTRACT_PARAMETERS within {PARAMETERS, ACTIVE_CONTRACTS} :=
{p in PARAMETERS, Cid in ACTIVE_CONTRACTS: parameter_period[p] = "Day"
and contract_parameter[p,Cid] = "Yes" } ;
# Set corresponding to daily contract data
set DC_DATA within {DAYS, CONTRACTS, PARAMETERS};
# Contract parameter data: daily data
param daily_contract_data {DC_DATA};
#
# PROBLEM statement starts here
#
#
#####
#
param effective_MDQ {t in DAYS, Cid in SUPPLY_CONTRACTS} =
max {(p,Cid) in DAILY_CONTRACT_PARAMETERS : P2[p] = 1}
daily_contract_data[t,Cid,p];
#
#####
#
#
# PROBLEM statement ends here
#
# display the values
printf "\n"; display DAYS;
printf "\n"; display CONTRACTS;
printf "\n"; display PARAMETERS;
printf "\n"; display DAILY_CONTRACT_PARAMETERS;
printf "\n"; display daily_contract_data;
printf "\n";
printf {t in DAYS, (p, Cid) in {(p,Cid) in DAILY_CONTRACT_PARAMETERS :
P2[p] = 1}}
"%d %s %s %4d\n", t, Cid, p, daily_contract_data[t,Cid,p];
printf "\nEffective_MDQ should give max value for each contract\n";
display effective_MDQ;
printf "\n";
data;
param : DAYS : date v1 v2 :=
1 40969 1 25
2 40970 2 25
3 40971 3 25
;
set CONTRACTS :=
CONTRACT1 CONTRACT2 CONTRACT3 CONTRACT4
;
param : PARAMETERS : parameter_period P1 P2 P3 :=
C_Active NA 0 0 0
Ctype NA 0 0 0
CP Day 0 0 0
DCQ Day 1 1 1
MinDQ Day 1 0 0
MDQ Day 0 1 0
REDQ Day 0 1 0
DToP Day 0 0 1
MDBQ Month 0 0 0
MDWQ Month 0 0 0
MCQ Month 0 0 0
MinMQ Month 1 0 0
MMQ Month 0 1 0
MToP Month 0 0 1
ACQ Year 0 0 0
MinAQ Year 1 0 0
MAQ Year 0 1 0
AToP Year 0 0 1
BPeriod NA 0 0 0
BStart NA 0 0 0
BLength NA 0 0 0
BDate Day 0 0 0
Ncd NA 0 0 0
RecoveryLength NA 0 0 0
MDTQ Day 0 1 0
REDTQ Day 0 1 0
TCP Day 0 0 0
TVP Day 0 0 0
MIR Day 0 0 0
IP Day 0 0 0
MWR Day 0 0 0
WP Day 0 0 0
SL Day 0 0 0
SP Day 0 0 0
Year Day 0 0 0
Month Day 0 0 0
;
param contract_parameter : CONTRACT1 CONTRACT2 CONTRACT3 CONTRACT4
:=
C_Active Yes Yes Yes Yes
Ctype supply supply supply supply
CP Yes Yes Yes Yes
DCQ Yes Yes Yes No
MinDQ No No Yes Yes
MDQ Yes Yes Yes Yes
REDQ Yes Yes No No
DToP Yes No No No
MDBQ No No No No
MDWQ No No No No
MCQ No No No No
MinMQ No No Yes No
MMQ No No No No
MToP No No Yes No
ACQ No No No No
MinAQ No No No No
MAQ No No No Yes
AToP No Yes No No
BPeriod Yes Yes No No
BStart Yes Yes No No
BLength Yes Yes No No
BDate Yes Yes No No
RecoveryLength Yes Yes No No
MDTQ No No No No
REDTQ No No No No
TCP No No No No
TVP No No No No
MIR No No No No
IP No No No No
MWR No No No No
WP No No No No
SL No No No No
SP No No No No
Year No Yes No No
Month No No No No
;
param : DC_DATA : daily_contract_data :=
1 CONTRACT1 CP 7
2 CONTRACT1 CP 7
3 CONTRACT1 CP 7
1 CONTRACT1 DCQ 72.7
2 CONTRACT1 DCQ 72.7
3 CONTRACT1 DCQ 72.7
1 CONTRACT1 MDQ 72.7
2 CONTRACT1 MDQ 72.7
3 CONTRACT1 MDQ 72.7
1 CONTRACT1 REDQ 77.7
2 CONTRACT1 REDQ 77.7
3 CONTRACT1 REDQ 77.7
1 CONTRACT1 DToP 72.7
2 CONTRACT1 DToP 72.7
3 CONTRACT1 DToP 72.7
1 CONTRACT1 BDate 1
2 CONTRACT1 BDate 0
3 CONTRACT1 BDate 0
1 CONTRACT2 CP 3
2 CONTRACT2 CP 3
3 CONTRACT2 CP 3
1 CONTRACT2 DCQ 23
2 CONTRACT2 DCQ 0
3 CONTRACT2 DCQ 0
1 CONTRACT2 MDQ 25.3
2 CONTRACT2 MDQ 25.3
3 CONTRACT2 MDQ 25.3
1 CONTRACT2 REDQ 25.3
2 CONTRACT2 REDQ 25.3
3 CONTRACT2 REDQ 25.3
1 CONTRACT2 BDate 0
2 CONTRACT2 BDate 0
3 CONTRACT2 BDate 0
1 CONTRACT2 Year 2012
2 CONTRACT2 Year 2012
3 CONTRACT2 Year 2012
1 CONTRACT3 CP 4.75
2 CONTRACT3 CP 4.75
3 CONTRACT3 CP 4.75
1 CONTRACT3 DCQ 15
2 CONTRACT3 DCQ 15
3 CONTRACT3 DCQ 15
1 CONTRACT3 MinDQ 15
2 CONTRACT3 MinDQ 15
3 CONTRACT3 MinDQ 15
1 CONTRACT3 MDQ 15
2 CONTRACT3 MDQ 15
3 CONTRACT3 MDQ 15
1 CONTRACT4 CP 3
2 CONTRACT4 CP 3
3 CONTRACT4 CP 3
1 CONTRACT4 MinDQ -7
2 CONTRACT4 MinDQ -7
3 CONTRACT4 MinDQ -7
1 CONTRACT4 MDQ -7
2 CONTRACT4 MDQ -7
3 CONTRACT4 MDQ -7
1 CONTRACT4 Year 2012
2 CONTRACT4 Year 2012
3 CONTRACT4 Year 2012
;
end;
-----
Dr. Harley Mackenzie
HARD software
address@hidden
www.hardsoftware.com
+ 61 3 5222 3435
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-glpk] Conversion of AMPL model defect #2,
Harley Mackenzie <=