[AMPL 13861] Error at _cmdno 8 executing "let" command

classic Classic list List threaded Threaded
5 messages Options
M H
Reply | Threaded
Open this post in threaded view
|

[AMPL 13861] Error at _cmdno 8 executing "let" command

M H
Hi,
I am trying to execute a code resembling the bayesian classifier , it is part of a larger code, the error message that I keep getting is:


Error at _cmdno 8 executing "let" command
(file m2.mod, line 30, offset 1814):
        no value for input[1,1,8]
if you check the dat file, you can see that there is a value for input[1,1,8]
the model:

set days=1..12;
param NOD = sum{d in days}1;            

set inputs = 1..5;                      
param NOI = sum{i in inputs}1;          

set users= 8..10;                       
param NOU = sum{u in users}1;           

param input {i in inputs, d in days, u in users};

set Values{inputs} ordered;             
let Values[1] := {1, 2, 3};             
let Values[2] := {1, 2, 3};             
let Values[3] := {1, 2, 3};             
let Values[4] := {1, 2, 3};             
let Values[5] := {1, 2};                

param NOV{i in inputs} = sum{v in Values[i]}1;      # determine the value of the parameter NOV for each Value[i] --> NOV[1]=3 ... NOV[5]=2

param conditional_probability{i in inputs,Values[i],Values[5], u in users} default 0;

for {i in 1..NOI, v in 1..NOV[i], c in 1..NOV[5], u in users}  let conditional_probability[i,v,c,u] := sum{d in days: input [i,d,u]=v && input[5,d,u]=c}1/sum{d1 in days:input[5,d1,u]=c}1;

#///////////////testing vector/////////////////////
param test_input {inputs} default 0;
let test_input [1]:=1; 
let test_input [2]:=1; 
let test_input [3]:=1; 
let test_input [4]:=2; 
param W{u in users} = (sum{d in days:input[5,d,u]=1}1/NOD) * (prod{i in 1..4} conditional_probability[i,test_input[i],1,u]) ;                     # the probability 


the Dat file:

param input  :=
[*,*,8]:              1 2 3      4  5 :=
1 3 3 2 1 1
2 2 2 2 2 1
3 1 1 1 1 1
4 1 3 2 2 1
5 3 3 3 2 1
6 2 2 1 1 2
7 1 2 1 1 1
8 2 3 3 1 1
9 3 2 1 1 1
10 2 3 3 2 1
11 2 2 2 2 1
12 1 3 3 3 1


[*,*,9]:              1 2 3 4 5 :=
1 2 1 1 1 1
2 2 1 1 2 1
3 3 2 1 3 1
4 2 3 3 3 1
5 3 2 1 2 1
6 2 2 1 1 1
7 3 3 2 2 1
8 3 3 2 1 1
9 3 2 2 1 1
10 2 1 1 2 1
11 1 3 3 3 1
12 2 3 1 2 1


[*,*,10]:            1 2 3 4 5 :=
1 2 2 1 1 1
2 2 1 1 1 1
3 3 2 1 1 1
4 2 3 3 1 1
5 3 2 1 3 1
6 3 3 3 1 1
7 2 3 3 1 1
8 3 2 1 1 1
9 1 2 1 1 1
10 3 3 2 2 1
11 2 3 1 2 1
12 2 3 3 2 1 ;




--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: [AMPL 13867] Error at _cmdno 8 executing "let" command

Robert Fourer-2
It appears that you are instructing AMPL to read a model file that includes this loop over assignment statements:

  for {i in 1..NOI, v in 1..NOV[i], c in 1..NOV[5], u in users}  
    let conditional_probability[i,v,c,u] :=
      sum{d in days: input [i,d,u]=v && input[5,d,u]=c}1/sum{d1 in days:input[5,d1,u]=c}1;

To execute these assignments, AMPL needs to know values for param input.  But at the point where the assignment is made, AMPL does not have any values for param input, because the data file has not yet been read.  Thus you get the "no value for input[1,1,8]" error message.  (In fact none of the values for param input are known yet, but input[1,1,8] is the first reference to param input that AMPL encounters when executing the loop.)

You can fix this problem by moving the "for" loop to the end of the data file, after all of the data statements, or by putting it in a "run" file that you include after the model and data have been read.

(You will also find that in your data file the tables are transposed, so that you need to replace "[*,*,8]:" by "[*,*,8] (tr):" and similarly for 9 and 10.)

Bob Fourer
[hidden email]

=======

From: [hidden email] [mailto:[hidden email]] On Behalf Of M H
Sent: Saturday, April 15, 2017 9:43 AM
To: AMPL Modeling Language
Subject: [AMPL 13861] Error at _cmdno 8 executing "let" command

I am trying to execute a code resembling the bayesian classifier , it is part of a larger code, the error message that I keep getting is:

Error at _cmdno 8 executing "let" command
(file m2.mod, line 30, offset 1814):
        no value for input[1,1,8]
if you check the dat file, you can see that there is a value for input[1,1,8]


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
M H
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 13909] Error at _cmdno 8 executing "let" command

M H
Thank you very much Bob, it worked and am getting my results,, many thanks



On Monday, April 17, 2017 at 2:53:22 AM UTC+1, Robert Fourer wrote:
It appears that you are instructing AMPL to read a model file that includes this loop over assignment statements:

  for {i in 1..NOI, v in 1..NOV[i], c in 1..NOV[5], u in users}  
    let conditional_probability[i,v,c,u] :=
      sum{d in days: input [i,d,u]=v && input[5,d,u]=c}1/sum{d1 in days:input[5,d1,u]=c}1;

To execute these assignments, AMPL needs to know values for param input.  But at the point where the assignment is made, AMPL does not have any values for param input, because the data file has not yet been read.  Thus you get the "no value for input[1,1,8]" error message.  (In fact none of the values for param input are known yet, but input[1,1,8] is the first reference to param input that AMPL encounters when executing the loop.)

You can fix this problem by moving the "for" loop to the end of the data file, after all of the data statements, or by putting it in a "run" file that you include after the model and data have been read.

(You will also find that in your data file the tables are transposed, so that you need to replace "[*,*,8]:" by "[*,*,8] (tr):" and similarly for 9 and 10.)

Bob Fourer
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="8X-rI6KmCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...

=======

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="8X-rI6KmCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="8X-rI6KmCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...] On Behalf Of M H
Sent: Saturday, April 15, 2017 9:43 AM
To: AMPL Modeling Language
Subject: [AMPL 13861] Error at _cmdno 8 executing "let" command

I am trying to execute a code resembling the bayesian classifier , it is part of a larger code, the error message that I keep getting is:

Error at _cmdno 8 executing "let" command
(file m2.mod, line 30, offset 1814):
        no value for input[1,1,8]
if you check the dat file, you can see that there is a value for input[1,1,8]


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
M H
Reply | Threaded
Open this post in threaded view
|

[AMPL 16121] Re: Error at _cmdno 8 executing "let" command

M H
In reply to this post by M H
Dear Bob,
I hope this message finds you well and thanks again for helping me out.

I am now trying to run several instances of the .dat file. using one .mod file. 
I found a description that matches what I need in the AMPL book. I used the code page 273 with me modifications as shown below:

model mlog.mod; 
set CASES = 1 .. 3;
       for {jj in CASES} {
          
          data ("mm_" & jj & ".dat");
          solve;
          display SINR >("result" & jj & ".txt");
  reset data;
       }
The above code produced a single (result_1.txt) file and then gave the following error messages:

ampl: include loopmm.run;
CPLEX 12.5.0.0: optimal integer solution; objective 4892.334888
197471 MIP simplex iterations
3139 branch-and-bound nodes
Error at _cmdno 210 executing "for" command
(file mm_2.dat, line 116, offset 3794):
error processing param NOV[1]:
        no value for Values[1]
Error at _cmdno 211 executing "solve" command
(file loopmm.run, line 7, offset 130):
error processing objective concave:
        no value for UW[8]
ampl:

Can you please advise ?


Note: I tried to run the same code mentioned on page 273 (without changing the place of the reset data; command but it didn't even work (not a single result files) and it gave me the following output:

ampl: include loopmm.run;
Error at _cmdno 34 executing "for" command
(file mm_1.dat, line 116, offset 3808):
error processing param NOV[1]:
        no value for Values[1]
Error at _cmdno 35 executing "solve" command
(file loopmm.run, line 7, offset 141):
error processing objective concave:
        no value for UW[8]
ampl: 


On Saturday, April 15, 2017 at 3:42:49 PM UTC+1, M H wrote:
Hi,
I am trying to execute a code resembling the bayesian classifier , it is part of a larger code, the error message that I keep getting is:


Error at _cmdno 8 executing "let" command
(file m2.mod, line 30, offset 1814):
        no value for input[1,1,8]
if you check the dat file, you can see that there is a value for input[1,1,8]
the model:

set days=1..12;
param NOD = sum{d in days}1;            

set inputs = 1..5;                      
param NOI = sum{i in inputs}1;          

set users= 8..10;                       
param NOU = sum{u in users}1;           

param input {i in inputs, d in days, u in users};

set Values{inputs} ordered;             
let Values[1] := {1, 2, 3};             
let Values[2] := {1, 2, 3};             
let Values[3] := {1, 2, 3};             
let Values[4] := {1, 2, 3};             
let Values[5] := {1, 2};                

param NOV{i in inputs} = sum{v in Values[i]}1;      # determine the value of the parameter NOV for each Value[i] --> NOV[1]=3 ... NOV[5]=2

param conditional_probability{i in inputs,Values[i],Values[5], u in users} default 0;

for {i in 1..NOI, v in 1..NOV[i], c in 1..NOV[5], u in users}  let conditional_probability[i,v,c,u] := sum{d in days: input [i,d,u]=v && input[5,d,u]=c}1/sum{d1 in days:input[5,d1,u]=c}1;

#///////////////testing vector/////////////////////
param test_input {inputs} default 0;
let test_input [1]:=1; 
let test_input [2]:=1; 
let test_input [3]:=1; 
let test_input [4]:=2; 
param W{u in users} = (sum{d in days:input[5,d,u]=1}1/NOD) * (prod{i in 1..4} conditional_probability[i,test_input[i],1,u]) ;                     # the probability 


the Dat file:

param input  :=
[*,*,8]:              1 2 3      4  5 :=
1 3 3 2 1 1
2 2 2 2 2 1
3 1 1 1 1 1
4 1 3 2 2 1
5 3 3 3 2 1
6 2 2 1 1 2
7 1 2 1 1 1
8 2 3 3 1 1
9 3 2 1 1 1
10 2 3 3 2 1
11 2 2 2 2 1
12 1 3 3 3 1


[*,*,9]:              1 2 3 4 5 :=
1 2 1 1 1 1
2 2 1 1 2 1
3 3 2 1 3 1
4 2 3 3 3 1
5 3 2 1 2 1
6 2 2 1 1 1
7 3 3 2 2 1
8 3 3 2 1 1
9 3 2 2 1 1
10 2 1 1 2 1
11 1 3 3 3 1
12 2 3 1 2 1


[*,*,10]:            1 2 3 4 5 :=
1 2 2 1 1 1
2 2 1 1 1 1
3 3 2 1 1 1
4 2 3 3 1 1
5 3 2 1 3 1
6 3 3 3 1 1
7 2 3 3 1 1
8 3 2 1 1 1
9 1 2 1 1 1
10 3 3 2 2 1
11 2 3 1 2 1
12 2 3 3 2 1 ;




--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16124] Re: Error at _cmdno 8 executing "let" command

AMPL mailing list
It seems that you have defined a param NOV{1..n}, but didn't assign the value to NOV[1] in your data file. I would suggest you to check your data file and make sure you have data for all the indices that you have defined in model file.

Thanks
Paras

--
Paras Tiwari
[hidden email]
{#HS:557617607-4789#}
On Mon, Apr 9, 2018 at 3:13 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Dear Bob,
I hope this message finds you well and thanks again for helping me out.

I am now trying to run several instances of the .dat file. using one .mod file.
I found a description that matches what I need in the AMPL book. I used the code page 273 with me modifications as shown below:

model mlog.mod;
set CASES = 1 .. 3;
for {jj in CASES} {
data ("mm_" & jj & ".dat");
solve;
display SINR >("result" & jj & ".txt");
reset data;
}
The above code produced a single (result_1.txt) file and then gave the following error messages:

ampl: include loopmm.run;
CPLEX 12.5.0.0: optimal integer solution; objective 4892.334888
197471 MIP simplex iterations
3139 branch-and-bound nodes
Error at _cmdno 210 executing "for" command
(file mm_2.dat, line 116, offset 3794):
error processing param NOV[1]:
no value for Values[1]
Error at _cmdno 211 executing "solve" command
(file loopmm.run, line 7, offset 130):
error processing objective concave:
no value for UW[8]
ampl:

Can you please advise ?


Note: I tried to run the same code mentioned on page 273 (without changing the place of the reset data; command but it didn't even work (not a single result files) and it gave me the following output:

ampl: include loopmm.run;
Error at _cmdno 34 executing "for" command
(file mm_1.dat, line 116, offset 3808):
error processing param NOV[1]:
no value for Values[1]
Error at _cmdno 35 executing "solve" command
(file loopmm.run, line 7, offset 141):
error processing objective concave:
no value for UW[8]
ampl:


On Saturday, April 15, 2017 at 3:42:49 PM UTC+1, M H wrote:
Hi,
I am trying to execute a code resembling the bayesian classifier , it is part of a larger code, the error message that I keep getting is:


Error at _cmdno 8 executing "let" command
(file m2.mod, line 30, offset 1814):
no value for input[1,1,8]
if you check the dat file, you can see that there is a value for input[1,1,8]
the model:

set days=1..12;
param NOD = sum{d in days}1;

set inputs = 1..5;
param NOI = sum{i in inputs}1;

set users= 8..10;
param NOU = sum{u in users}1;

param input {i in inputs, d in days, u in users};

set Values{inputs} ordered;
let Values[1] := {1, 2, 3};
let Values[2] := {1, 2, 3};
let Values[3] := {1, 2, 3};
let Values[4] := {1, 2, 3};
let Values[5] := {1, 2};

param NOV{i in inputs} = sum{v in Values[i]}1; # determine the value of the parameter NOV for each Value[i] --> NOV[1]=3 ... NOV[5]=2

param conditional_probability{i in inputs,Values[i],Values[5], u in users} default 0;

for {i in 1..NOI, v in 1..NOV[i], c in 1..NOV[5], u in users} let conditional_probability[i,v,c,u] := sum{d in days: input [i,d,u]=v && input[5,d,u]=c}1/sum{d1 in days:input[5,d1,u]=c}1;

#///////////////testing vector/////////////////////
param test_input {inputs} default 0;
let test_input [1]:=1;
let test_input [2]:=1;
let test_input [3]:=1;
let test_input [4]:=2;
param W{u in users} = (sum{d in days:input[5,d,u]=1}1/NOD) * (prod{i in 1..4} conditional_probability[i,test_input[i],1,u]) ; # the probability


the Dat file:

param input :=
[*,*,8]: 1 2 3 4 5 :=
1 3 3 2 1 1
2 2 2 2 2 1
3 1 1 1 1 1
4 1 3 2 2 1
5 3 3 3 2 1
6 2 2 1 1 2
7 1 2 1 1 1
8 2 3 3 1 1
9 3 2 1 1 1
10 2 3 3 2 1
11 2 2 2 2 1
12 1 3 3 3 1


[*,*,9]: 1 2 3 4 5 :=
1 2 1 1 1 1
2 2 1 1 2 1
3 3 2 1 3 1
4 2 3 3 3 1
5 3 2 1 2 1
6 2 2 1 1 1
7 3 3 2 2 1
8 3 3 2 1 1
9 3 2 2 1 1
10 2 1 1 2 1
11 1 3 3 3 1
12 2 3 1 2 1


[*,*,10]: 1 2 3 4 5 :=
1 2 2 1 1 1
2 2 1 1 1 1
3 3 2 1 1 1
4 2 3 3 1 1
5 3 2 1 3 1
6 3 3 3 1 1
7 2 3 3 1 1
8 3 2 1 1 1
9 1 2 1 1 1
10 3 3 2 2 1
11 2 3 1 2 1
12 2 3 3 2 1 ;




--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.