error message: bad e->a in heswork

View: New views
4 Messages — Rating Filter:   Alert me  

error message: bad e->a in heswork

by Steven Joyce () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm getting the following error message when I try to solve my model:

bad e->a = 400603 in heswork

Can anyone help me figure out what this message is trying to tell me?

I'm running AMPL version 20080307 with solver KNITRO 5.2.0.

[AMPL 1799] Re: error message: bad e->a in heswork

by Robert Fourer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



This is a "bad pointer address" message which typically indicates an obscure
bug of some kind.  The problem might be in KNITRO or it might be in the
AMPL-solver library.  Could you send me your model and data?  Once I can
reproduce this error, I'm sure it can be fixed quickly.

As a temporary workaround, you might try setting

   option knitro_options 'algorithm=1';

and similarly algorithm=2 or algorithm=3.  One of these should give the same
error that you're currently getting, but the other two will attempt to solve
your problem in different ways and might be successful.

Bob Fourer
4er@...


> -----Original Message-----
> From: ampl@... [mailto:ampl@...] On Behalf Of
> Steven Joyce
> Sent: Sunday, May 25, 2008 8:12 AM
> To: ampl@...
> Subject: [AMPL 1798] error message: bad e->a in heswork
>
> I'm getting the following error message when I try to solve my model:
>
> bad e->a = 400603 in heswork
>
> Can anyone help me figure out what this message is trying to tell me?
>
> I'm running AMPL version 20080307 with solver KNITRO 5.2.0.
>
> --
> View this message in context: http://www.nabble.com/error-message%3A-bad-
> e-%3Ea-in-heswork-tp17430124p17430124.html
> Sent from the AMPL mailing list archive at Nabble.com.
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [AMPL 1799] Re: error message: bad e->a in heswork

by Steven Joyce :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1) I get the same error message with all three algorithms.

2) Right now, I'm just testing the code, so the mod file randomly generates its own data rather than using actual data from a separate file.

3) I'm including the mod file.  Let me know if you also need the run file.

Here is the model file (pd-multi.mod):
-----------------------
# pd-multi.mod

# Estimates a price discrimination model using MSM
# Demand side only
# Multiple markets
# Duopoly in each market
# Single-product firms

# Structural parameters
param nSims = 1000;
param nChar = 3; # Demand characteristics excluding price
param nInst = 2*nChar;
param nMarkets = 100;
param nProducts = 2;
param nConsumers = 5000;
param TrueSigma = 1;
param TrueAlpha = 1;
param TrueTheta {1..nChar} = 1;

# Raw data parameters
param ExogChar {1..nMarkets,1..nProducts,k in 1..nChar} =
    (if k=1 then 1 else Normal(0,1));
param TrueXi {1..nMarkets,1..nProducts} = Normal(0,0.1);
param TrueNu {1..nMarkets,1..nConsumers} = Normal01();
param SelectDraw {1..nMarkets,1..nConsumers} = Uniform01();

# Constructed structural parametres
param TrueDelta {m in 1..nMarkets, j in 1..nProducts} =
    TrueXi[m,j] + sum {k in 1..nChar} ExogChar[m,j,k]*TrueTheta[k];
param TrueMeanPriceOffer {m in 1..nMarkets, j in 1..nProducts} =
    + 0.5*(sum {k in 1..nChar} ExogChar[m,j,k]*TrueTheta[k])
    - 0.2*(sum {j2 in 1..nProducts diff {j}}
           sum {k in 1..nChar} ExogChar[m,j2,k]*TrueTheta[k]);
param TrueStdDevPriceOffer {m in 1..nMarkets, j in 1..nProducts} =
    Uniform(0,TrueSigma/TrueAlpha);

# Constructed data parameters
param TruePriceOffer
    {m in 1..nMarkets,j in 1..nProducts,i in 1..nConsumers} =
    TrueMeanPriceOffer[m,j] + TrueStdDevPriceOffer[m,j]*TrueNu[m,i];
param TrueTop {m in 1..nMarkets, j in 1..nProducts, i in 1..nConsumers} =
    TrueDelta[m,j] - TrueAlpha*TruePriceOffer[m,j,i] +
    TrueSigma*TrueNu[m,i];
param MaxTrueTop {m in 1..nMarkets, i in 1..nConsumers} =
    max {j in 1..nProducts} TrueTop[m,j,i];
param TrueShare {m in 1..nMarkets,j in 1..nProducts,i in 1..nConsumers} =
    exp(TrueTop[m,j,i] - MaxTrueTop[m,i]) /
    (exp(-MaxTrueTop[m,i]) +
     sum {j2 in 1..nProducts} exp(TrueTop[m,j2,i]-MaxTrueTop[m,i]));
param CumTrueShare {m in 1..nMarkets,j in 0..nProducts,i in 1..nConsumers} =
    sum {j2 in 1..j} TrueShare[m,j2,i];
set OBSERVED {m in 1..nMarkets, j in 1..nProducts} =
    {i in 1..nConsumers:
     CumTrueShare[m,j-1,i] <=
     SelectDraw[m,i] <
     CumTrueShare[m,j,i]};
set INSIDE {m in 1..nMarkets} =
    union {j in 1..nProducts} OBSERVED[m,j];
param nObs {m in 1..nMarkets, j in 1..nProducts} =
    card(OBSERVED[m,j]);
param FirmID {m in 1..nMarkets, i in INSIDE[m]} =
    max {j in 1..nProducts : i in OBSERVED[m,j]} j;
param ActuPriceMoment1 {m in 1..nMarkets, j in 1..nProducts} =
    (1/nObs[m,j]) * sum {i in OBSERVED[m,j]} TruePriceOffer[m,j,i];
param ActuPriceMoment2 {m in 1..nMarkets, j in 1..nProducts} =
    (1/nObs[m,j]) * sum {i in OBSERVED[m,j]} TruePriceOffer[m,j,i]^2;

# Simulation Draws
param SimNu {1..nMarkets,1..nSims} = Normal01();

# Structural variables
var Sigma >= 0;
let Sigma := TrueSigma;
fix Sigma;

var Alpha >= 0;
var Theta {1..nChar};
var Delta {1..nMarkets, j in 1..nProducts};
var MeanPriceOffer {1..nMarkets, j in 1..nProducts};
var StdDevPriceOffer {1..nMarkets, j in 1..nProducts} >= 0;

# Constrcuted variables
param Inst {m in 1..nMarkets, j in 1..nProducts, k in 1..nInst} =
    (if k <= nChar
     then ExogChar[m,j,k]
     else sum {j2 in 1..nProducts} ExogChar[m,j2,k-nChar]
    );
var SimPriceOffer {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    MeanPriceOffer[m,j] + StdDevPriceOffer[m,j]*SimNu[m,i];
var SimTop {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    Delta[m,j] - Alpha*SimPriceOffer[m,j,i] + Sigma*SimNu[m,i];
var MaxSimTop {m in 1..nMarkets,i in 1..nSims} =
    max {j in 1..nProducts} SimTop[m,j,i];
var SimShare {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    exp(SimTop[m,j,i]-MaxSimTop[m,i]) /
    (exp(-MaxSimTop[m,i]) +
     sum {j2 in 1..nProducts} exp(SimTop[m,j,i]-MaxSimTop[m,i]));
var SumWeights {m in 1..nMarkets, j in  1..nProducts} =
    sum {i in 1..nSims} SimShare[m,j,i];
var PredPriceMoment1 {m in 1..nMarkets, j in 1..nProducts} =
    (sum {i in 1..nSims} SimShare[m,j,i]*SimPriceOffer[m,j,i]) /
    SumWeights[m,j];
var PredPriceMoment2 {m in 1..nMarkets, j in 1..nProducts} =
    (sum {i in 1..nSims}
     SimShare[m,j,i] *
     (SimPriceOffer[m,j,i]-PredPriceMoment1[m,j])^2) /
    SumWeights[m,j];
var PredShare {m in 1..nMarkets, j in 1..nProducts} =
    (1/nSims) * SumWeights[m,j];

# Objective function
minimize gmm:
    + sum {m in 1..nMarkets, j in 1..nProducts}
    (
     + (ActuPriceMoment1[m,j] - PredPriceMoment1[m,j])^2
     + (ActuPriceMoment2[m,j] -
        2*ActuPriceMoment1[m,j]*PredPriceMoment1[m,j] +
        PredPriceMoment1[m,j]^2 - PredPriceMoment2[m,j])^2
    )
    + sum {k in 1..nInst}
    (sum {m in 1..nMarkets, j in 1..nProducts}
     Inst[m,j,k]*
     (Delta[m,j] - sum {k2 in 1..nChar} ExogChar[m,j,k2]*Theta[k2])
    )^2;

# Constraints
subject to ShareMatch {m in 1..nMarkets, j in 1..nProducts}:
    nObs[m,j]/nConsumers = PredShare[m,j];

-----------------------

Robert Fourer-2 wrote:

This is a "bad pointer address" message which typically indicates an obscure
bug of some kind.  The problem might be in KNITRO or it might be in the
AMPL-solver library.  Could you send me your model and data?  Once I can
reproduce this error, I'm sure it can be fixed quickly.

As a temporary workaround, you might try setting

   option knitro_options 'algorithm=1';

and similarly algorithm=2 or algorithm=3.  One of these should give the same
error that you're currently getting, but the other two will attempt to solve
your problem in different ways and might be successful.

Bob Fourer
4er@ampl.com


> -----Original Message-----
> From: ampl@googlegroups.com [mailto:ampl@googlegroups.com] On Behalf Of
> Steven Joyce
> Sent: Sunday, May 25, 2008 8:12 AM
> To: ampl@googlegroups.com
> Subject: [AMPL 1798] error message: bad e->a in heswork
>
> I'm getting the following error message when I try to solve my model:
>
> bad e->a = 400603 in heswork
>
> Can anyone help me figure out what this message is trying to tell me?
>
> I'm running AMPL version 20080307 with solver KNITRO 5.2.0.
>
> --
> View this message in context: http://www.nabble.com/error-message%3A-bad-
> e-%3Ea-in-heswork-tp17430124p17430124.html
> Sent from the AMPL mailing list archive at Nabble.com.
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@googlegroups.com
To unsubscribe from this group, send email to ampl-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: [AMPL 1799] Re: error message: bad e->a in heswork

by Steven Joyce :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I hate to reply to my own message, but I think I found the source of the error.

The problematic line is this one:

var MaxSimTop {m in 1..nMarkets,i in 1..nSims} =
    max {j in 1..nProducts} SimTop[m,j,i];

(the same problem occurs with the line defining MaxTrueTop)

At points where two or more values of SimTop are equal to the maximum, the gradient of MaxSimTop with respect to those values is kinked, and thus the Hessian is undefined.  AMPL and/or KINTRO objects to this.  Now, in my model, MaxSimTop is used for only one purpose -- I multiply both the numerator and denominator of SimShare by exp(-MaxTrueTop).  This is a kludge in order to get the correct value for SimShare when, due to overflow, it would otherwise evaluate to Infinity/Infinity = NaN.  I've managed to cut this kludge while avoiding overflow by more carefully selecting initial values.


1) I get the same error message with all three algorithms.

2) Right now, I'm just testing the code, so the mod file randomly generates its own data rather than using actual data from a separate file.

3) I'm including the mod file.  Let me know if you also need the run file.

Here is the model file (pd-multi.mod):
-----------------------
# pd-multi.mod

# Estimates a price discrimination model using MSM
# Demand side only
# Multiple markets
# Duopoly in each market
# Single-product firms

# Structural parameters
param nSims = 1000;
param nChar = 3; # Demand characteristics excluding price
param nInst = 2*nChar;
param nMarkets = 100;
param nProducts = 2;
param nConsumers = 5000;
param TrueSigma = 1;
param TrueAlpha = 1;
param TrueTheta {1..nChar} = 1;

# Raw data parameters
param ExogChar {1..nMarkets,1..nProducts,k in 1..nChar} =
    (if k=1 then 1 else Normal(0,1));
param TrueXi {1..nMarkets,1..nProducts} = Normal(0,0.1);
param TrueNu {1..nMarkets,1..nConsumers} = Normal01();
param SelectDraw {1..nMarkets,1..nConsumers} = Uniform01();

# Constructed structural parametres
param TrueDelta {m in 1..nMarkets, j in 1..nProducts} =
    TrueXi[m,j] + sum {k in 1..nChar} ExogChar[m,j,k]*TrueTheta[k];
param TrueMeanPriceOffer {m in 1..nMarkets, j in 1..nProducts} =
    + 0.5*(sum {k in 1..nChar} ExogChar[m,j,k]*TrueTheta[k])
    - 0.2*(sum {j2 in 1..nProducts diff {j}}
           sum {k in 1..nChar} ExogChar[m,j2,k]*TrueTheta[k]);
param TrueStdDevPriceOffer {m in 1..nMarkets, j in 1..nProducts} =
    Uniform(0,TrueSigma/TrueAlpha);

# Constructed data parameters
param TruePriceOffer
    {m in 1..nMarkets,j in 1..nProducts,i in 1..nConsumers} =
    TrueMeanPriceOffer[m,j] + TrueStdDevPriceOffer[m,j]*TrueNu[m,i];
param TrueTop {m in 1..nMarkets, j in 1..nProducts, i in 1..nConsumers} =
    TrueDelta[m,j] - TrueAlpha*TruePriceOffer[m,j,i] +
    TrueSigma*TrueNu[m,i];
param MaxTrueTop {m in 1..nMarkets, i in 1..nConsumers} =
    max {j in 1..nProducts} TrueTop[m,j,i];
param TrueShare {m in 1..nMarkets,j in 1..nProducts,i in 1..nConsumers} =
    exp(TrueTop[m,j,i] - MaxTrueTop[m,i]) /
    (exp(-MaxTrueTop[m,i]) +
     sum {j2 in 1..nProducts} exp(TrueTop[m,j2,i]-MaxTrueTop[m,i]));
param CumTrueShare {m in 1..nMarkets,j in 0..nProducts,i in 1..nConsumers} =
    sum {j2 in 1..j} TrueShare[m,j2,i];
set OBSERVED {m in 1..nMarkets, j in 1..nProducts} =
    {i in 1..nConsumers:
     CumTrueShare[m,j-1,i] <=
     SelectDraw[m,i] <
     CumTrueShare[m,j,i]};
set INSIDE {m in 1..nMarkets} =
    union {j in 1..nProducts} OBSERVED[m,j];
param nObs {m in 1..nMarkets, j in 1..nProducts} =
    card(OBSERVED[m,j]);
param FirmID {m in 1..nMarkets, i in INSIDE[m]} =
    max {j in 1..nProducts : i in OBSERVED[m,j]} j;
param ActuPriceMoment1 {m in 1..nMarkets, j in 1..nProducts} =
    (1/nObs[m,j]) * sum {i in OBSERVED[m,j]} TruePriceOffer[m,j,i];
param ActuPriceMoment2 {m in 1..nMarkets, j in 1..nProducts} =
    (1/nObs[m,j]) * sum {i in OBSERVED[m,j]} TruePriceOffer[m,j,i]^2;

# Simulation Draws
param SimNu {1..nMarkets,1..nSims} = Normal01();

# Structural variables
var Sigma >= 0;
let Sigma := TrueSigma;
fix Sigma;

var Alpha >= 0;
var Theta {1..nChar};
var Delta {1..nMarkets, j in 1..nProducts};
var MeanPriceOffer {1..nMarkets, j in 1..nProducts};
var StdDevPriceOffer {1..nMarkets, j in 1..nProducts} >= 0;

# Constrcuted variables
param Inst {m in 1..nMarkets, j in 1..nProducts, k in 1..nInst} =
    (if k <= nChar
     then ExogChar[m,j,k]
     else sum {j2 in 1..nProducts} ExogChar[m,j2,k-nChar]
    );
var SimPriceOffer {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    MeanPriceOffer[m,j] + StdDevPriceOffer[m,j]*SimNu[m,i];
var SimTop {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    Delta[m,j] - Alpha*SimPriceOffer[m,j,i] + Sigma*SimNu[m,i];
var MaxSimTop {m in 1..nMarkets,i in 1..nSims} =
    max {j in 1..nProducts} SimTop[m,j,i];
var SimShare {m in 1..nMarkets,j in 1..nProducts,i in 1..nSims} =
    exp(SimTop[m,j,i]-MaxSimTop[m,i]) /
    (exp(-MaxSimTop[m,i]) +
     sum {j2 in 1..nProducts} exp(SimTop[m,j,i]-MaxSimTop[m,i]));
var SumWeights {m in 1..nMarkets, j in  1..nProducts} =
    sum {i in 1..nSims} SimShare[m,j,i];
var PredPriceMoment1 {m in 1..nMarkets, j in 1..nProducts} =
    (sum {i in 1..nSims} SimShare[m,j,i]*SimPriceOffer[m,j,i]) /
    SumWeights[m,j];
var PredPriceMoment2 {m in 1..nMarkets, j in 1..nProducts} =
    (sum {i in 1..nSims}
     SimShare[m,j,i] *
     (SimPriceOffer[m,j,i]-PredPriceMoment1[m,j])^2) /
    SumWeights[m,j];
var PredShare {m in 1..nMarkets, j in 1..nProducts} =
    (1/nSims) * SumWeights[m,j];

# Objective function
minimize gmm:
    + sum {m in 1..nMarkets, j in 1..nProducts}
    (
     + (ActuPriceMoment1[m,j] - PredPriceMoment1[m,j])^2
     + (ActuPriceMoment2[m,j] -
        2*ActuPriceMoment1[m,j]*PredPriceMoment1[m,j] +
        PredPriceMoment1[m,j]^2 - PredPriceMoment2[m,j])^2
    )
    + sum {k in 1..nInst}
    (sum {m in 1..nMarkets, j in 1..nProducts}
     Inst[m,j,k]*
     (Delta[m,j] - sum {k2 in 1..nChar} ExogChar[m,j,k2]*Theta[k2])
    )^2;

# Constraints
subject to ShareMatch {m in 1..nMarkets, j in 1..nProducts}:
    nObs[m,j]/nConsumers = PredShare[m,j];

-----------------------

Robert Fourer-2 wrote:

This is a "bad pointer address" message which typically indicates an obscure
bug of some kind.  The problem might be in KNITRO or it might be in the
AMPL-solver library.  Could you send me your model and data?  Once I can
reproduce this error, I'm sure it can be fixed quickly.

As a temporary workaround, you might try setting

   option knitro_options 'algorithm=1';

and similarly algorithm=2 or algorithm=3.  One of these should give the same
error that you're currently getting, but the other two will attempt to solve
your problem in different ways and might be successful.

Bob Fourer
4er@ampl.com


> -----Original Message-----
> From: ampl@googlegroups.com [mailto:ampl@googlegroups.com] On Behalf Of
> Steven Joyce
> Sent: Sunday, May 25, 2008 8:12 AM
> To: ampl@googlegroups.com
> Subject: [AMPL 1798] error message: bad e->a in heswork
>
> I'm getting the following error message when I try to solve my model:
>
> bad e->a = 400603 in heswork
>
> Can anyone help me figure out what this message is trying to tell me?
>
> I'm running AMPL version 20080307 with solver KNITRO 5.2.0.
>
> --
> View this message in context: http://www.nabble.com/error-message%3A-bad-
> e-%3Ea-in-heswork-tp17430124p17430124.html
> Sent from the AMPL mailing list archive at Nabble.com.
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@googlegroups.com
To unsubscribe from this group, send email to ampl-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---