help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Conversion of AMPL model defect #1


From: Harley Mackenzie
Subject: Re: [Help-glpk] Conversion of AMPL model defect #1
Date: Tue, 07 Aug 2012 22:12:28 +1000

Andrew,

The param fix for effective_MDQ worked very well, and there were a
number of other instances of assignment for params using '=' instead of
':='.

The fix for the BP variable is still causing issues. I have used your
version:

  param BP >= 0, := sum {t in DAYS, Cid in BANKING_CONTRACTS}
  (DBQ[t,Cid] + DWQ[t,Cid]) * 0.0001;

and I get a compilation error: "expression following := has invalid
type".

DBQ and DWQ are both variables defined as:

  var DBQ{DAYS, BANKING_CONTRACTS} >= 0;
  var DWQ{DAYS, BANKING_CONTRACTS} >= 0;

Apart from this issue, everything else is running now.

Regards,

harley

On Tue, Aug 7, 2012, at 21:05, Andrew Makhorin wrote:
> > I am presently working on converting a large AMPL/CPLEX model so I can
> > learn how the model works and also to compare the execution times with
> > CPLEX. I have managed to fix most of the obvious problems but I have a
> > couple of issues that I need to ask for help from the GLPK experts.
> > 
> > The first one is a syntactical one:
> > 
> > Here is the AMPL code:
> > 
> > var BP >= 0;
> > BP  = sum {t in DAYS, Cid in BANKING_CONTRACTS} (DBQ[t,Cid] +
> > DWQ[t,Cid]) * 0.0001 
> > 
> > This code fails with "BP multiply declared" error.
> > 
> > I thought it may have been an AMPL defined variable but I have tried a
> > number of different formulations using the WikiBook as a guide but
> > havent had any success.
> > 
> > Any ideas?
> > 
> 
> In constraint statements the 's.t.' keyword may be omitted, so the
> second statement is recognized as a constraint whose name is 'BP' (that
> statement is syntactically incorrect, because a colon should follow a
> constraint name). To fix the error you need to declare 'BP' as a
> parameter rather than a variable:
> 
> param BP >= 0, := sum {t in DAYS, Cid in BANKING_CONTRACTS} 
> (DBQ[t,Cid] + DWQ[t,Cid]) * 0.0001 ;
> 
> 
> > 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.
> > 
> 
> If the declaration
> 
> param foo = ...
> 
> the expression that follows '=' is a condition, which the parameter
> value should satisfy to. If you want to assign a value to a parameter,
> you need to use ':=' rather than '=', i.e.
> 
>   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];  
> 
> 
> 
-----
  Dr. Harley Mackenzie
  HARD software

  address@hidden
  www.hardsoftware.com
  + 61 3 5222 3435




reply via email to

[Prev in Thread] Current Thread [Next in Thread]