Printing the results

Hi,
I have linked a Hydraulic model(SWMM 5.0) to an optimization module (NSGA II) using c++ and called some results from the hydraulic model to the optimization module for an analysis.

However I am not too sure that I have called them correctly and wanted to print those results in a text file so that I can have a feedback.

Could anyone would like to help me to make the coding to print these results in a text file {O[i] and q[j]}.

Following coding are for running the program and for calling the results.

Thanks alot.


RunSwmmDll("f1.inp", "f2.rpt", "f3.out");

{


swmm_open("f1.inp", "f2.rpt", "f3.out");

{

float O[100], q[100];

double elapsedTime;

swmm_start(1);

{

do

{

swmm_step(&elapsedTime);

}

while(elapsedTime>0.0);



// First fitness function

for(t=0; t<=SWMM_Nperiods; t++)

{
OpenSwmmOutFile("f3.out");

{

GetSwmmResult(1, 8, 5, t, &O[0]);

GetSwmmResult(1, 9, 5, t, &O[1]);

GetSwmmResult(1, 10, 5, t, &O[2]);

GetSwmmResult(1, 11, 5, t, &O[3]);

GetSwmmResult(1, 12, 5, t, &O[4]);

GetSwmmResult(1, 13, 5, t, &O[5]);

GetSwmmResult(1, 14, 5, t, &O[6]);

GetSwmmResult(2, 0, 0, t, &q[0]);

GetSwmmResult(2, 1, 0, t, &q[1]);

GetSwmmResult(2, 2, 0, t, &q[2]);

GetSwmmResult(2, 3, 0, t, &q[3]);

GetSwmmResult(2, 4, 0, t, &q[4]);

GetSwmmResult(2, 5, 0, t, &q[5]);

GetSwmmResult(2, 6, 0, t, &q[6]);


}



for(i=0; i<=6; i++)

{
f[0]+=-O[i];

}


// Second Fitness Function


for(j=0; j<=6; j++)

{
f[0]+=q[j];

}

CloseSwmmOutFile();



}




}

swmm_end();

}

swmm_close();

}
Topic archived. No new replies allowed.