Originally posted by: guvenc
Hello people I dont know if it s right forum to ask this question but here is my problem. Thanks for your helps..
I have a thread in OPL using Cplex forum about this issue but the forum is under maintenance now and I am a bit stuck with this problem for five days.
In short I try to read data(problem instance) from a notepad file then solve a math model with the instance, give an output file and then read another input notepad file to solve again and again...
Below I have an(uncompleted) main script in which I want to read data from different .txt files consequtevly. The notepad files are named like those examples.
n20r1p1w1c1pr01.txt
n20r1p1w1c1pr02.txt
n50r1p1w1c1pr10.txt
20
1 80 85 5 60
2 122 127 5 50
....
19 189 198 9 40
20 124 132 8 40
Above is shown one of my notepad file.
In main; I try to assign the information inside the files to r,d,w and c in each iteration. I'll use those arrays in my math model.
I get an error when I write such lines in order to be able to itterate among notepad files.
*// var h6=new Array();
*// h6[0]='01';
*// h6[1]='02';
....
*// file.open("n"
h1"r"
h2"p"
h3"w"
h4"c"
h5"pr"
h6[0]".txt")//in each iteration I ll play with index of h
Internal error: ASSERTION FAILED at ..\..\..\src\script\extras.cpp:849
In this wy i expect to iterate among notepad files. h6[1]='02' h6[2]='03'
main
{
// r,d,w,c will be used as parameters in mathematical model
var r=new Array();
var d=new Array();
var w=new Array();
var c=new Array();
var index=1;
var file= new IloOplInputFile();
// HERE is Notepad File Names Logic
var h1='20';//20 50 100 500
var h2='1';
var h3='1';
var h4='1';//1 2 3
var h5='1';//1 2 3 4
var h6='01';//01 02 ... 10
var i=1;
while(i<=2)
{
file.open("n"
h1"r"
h2"p"
h3"w"
h4"c"
h5"pr"
h6".txt");//This works.
//file.open("n20r1p1w1c1pr01.txt");
var read;
var tmp;
if (file.isOpen)
{
writeln("f is open");
while (!file.eof)
{
read=file.readline();//reads line by line
writeln(read);
tmp=read.split("\t");
if(tmp[1]!=null)
{
r
index=tmp[1];
d
index=tmp[2];
w
index=tmp[3];
c
index=tmp[4];
writeln(r
index,"-",d
index,"-",w
index,"-",c
index);
index=index+1;
}
}
file.close();
}
else
{
writeln("f is closed");
}
if (file.isOpen)
writeln("f is open");
else
writeln("f is closed");
for(a=1;a<=20;a++)
write(r[a]," ");
h6='02';// I change here.
i=i+1; // This is just to try if i can get second file and it works as expected
}
}
Thanks a lot for your helps.
#CPLEXOptimizers#DecisionOptimization