Doubts in coding the consumption of around 100 houses

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Doubts in coding the consumption of around 100 houses

sohini dhar-2
Hii,
I am trying to calculate the total power consumption of approximately 100 households,each having similar type of appliances(supposingly).
I have written down this code.

What i want is that every house should have their consumption recorded after every 45 ticks.Based on the state array which shows the state of appliances as on(ie 1) or off(ie 0).
1.I am not understanding how to iterate through 100 houses..Will the j loop work..I am not sure.
2.Also what type of graph should I get on screen.I think it should be of type "Mean".
3.If i am taking the j loop i need to return back the power consumption for every house ,each house calculating after every 45 ticks.
4.there is some error in the code. but I am not understanding what.

public double[] getconsumption()
{
double[][] state = new double[100][5];
double[][] cons = new double[100][96];
double[] t_con = new double[96];
double[] sum =new double[100];
for(int j=1;j<=100;j++)
{
ISchedule schedule = RunEnvironment.getInstance().getCurrentSchedule();
        double time = schedule.getTickCount();
        
        if(time%45 == 0) /*considering 45 ticks as 15mins*/ 
        {
       
        for(int i=0;i<5;i++)
        {
       
        state[j][i] = RandomHelper.nextIntFromTo(0,1);
        if(state[j][0]==1)
        {
        sum[j] = sum[j]+getfancon();  
        }
       
        if(state[j][1]==1)
        {
        sum[j] = sum[j]+gettvcon();  
        }
       
        if(state[j][2]==1)
        {
        sum[j] = sum[j]+getfridgecon();  
        }
       
        if(state[j][3]==1)
        {
        sum[j] = sum[j]+gettubecon();  
        }
       
        if(state[j][4]==1)
        {
        sum[j] = sum[j]+getbulbcon();  
        }
        cons[j][i]=sum[j];
       
        }
       
    }
        for(int k=0;k<96;k++)
        {
        t_con [k] = cons[j][k];
       
        }
        
}
return t_con;
}
public double getfancon()
{
return 75;
}
public double gettvcon()
{
return 90;
}
public double getfridgecon()
{
return 200;
}
public double gettubecon()
{
return 40;
}
public double getbulbcon()
{
return 15;
}


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest