|
From: <mar...@us...> - 2007-10-04 06:03:36
|
Revision: 64
http://gridsim.svn.sourceforge.net/gridsim/?rev=64&view=rev
Author: marcos_dias
Date: 2007-10-03 23:03:39 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
This version contains many changes and bug fixes:
+ Some classes have been moved to gridsim.turbo package.
+ The ParallelSpaceShared policy has been changed substantially and some bugs have been fixed. For example, the policy was not compressing the schedule properly when cancelling a gridlet. This could also lead to finding the wrong anchor for a job when the completion of a job matched the completion of another job and there was a big job starting at this completion time.
+ Some advance reservation features have been provided, but they are still being tested.
+ Improvements in the graphical user interface have been made.
+ Some changes in SimJava classes have been made to remove the animation and log capabilities that are not used by GridSim.
Modified Paths:
--------------
branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java
branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java
branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java
branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_event.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_port.java
branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java
branches/gridsim4.0-branch3/source/gridsim/ARSimpleSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java
branches/gridsim4.0-branch3/source/gridsim/GridResource.java
branches/gridsim4.0-branch3/source/gridsim/GridSim.java
branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java
branches/gridsim4.0-branch3/source/gridsim/Gridlet.java
branches/gridsim4.0-branch3/source/gridsim/MachineList.java
branches/gridsim4.0-branch3/source/gridsim/ResGridletList.java
branches/gridsim4.0-branch3/source/gridsim/SpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/TimeShared.java
branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java
branches/gridsim4.0-branch3/source/gridsim/gui/AllocationListener.java
branches/gridsim4.0-branch3/source/gridsim/gui/AllocationSubject.java
branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java
branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java
branches/gridsim4.0-branch3/source/gridsim/net/BusLink.java
branches/gridsim4.0-branch3/source/gridsim/net/Output.java
branches/gridsim4.0-branch3/source/gridsim/services/MessageBody.java
branches/gridsim4.0-branch3/source/gridsim/services/Negotiation.java
branches/gridsim4.0-branch3/source/gridsim/services/NegotiationList.java
branches/gridsim4.0-branch3/source/gridsim/services/NegotiationMessage.java
branches/gridsim4.0-branch3/source/gridsim/services/index/GridServiceRepository.java
branches/gridsim4.0-branch3/source/gridsim/services/index/RegionalGSR.java
Added Paths:
-----------
branches/gridsim4.0-branch3/examples/examples/ar/
branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java
branches/gridsim4.0-branch3/examples/examples/workload/ar/
branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java
branches/gridsim4.0-branch3/source/gridsim/gui/ItemPanel.java
branches/gridsim4.0-branch3/source/gridsim/gui/ScheduleItem.java
branches/gridsim4.0-branch3/source/gridsim/turbo/
branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java
branches/gridsim4.0-branch3/source/gridsim/turbo/FilterARMessage.java
branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java
branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java
branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java
branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java
branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java
Removed Paths:
-------------
branches/gridsim4.0-branch3/examples/examples/ar/Example10.java
branches/gridsim4.0-branch3/examples/examples/ar/README.txt
branches/gridsim4.0-branch3/source/eduni/simdiag/
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reporter.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reportfile.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat_exception.java
branches/gridsim4.0-branch3/source/eduni/simjava/package.html
branches/gridsim4.0-branch3/source/gridsim/PERange.java
branches/gridsim4.0-branch3/source/gridsim/PERangeList.java
branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/SSGridlet.java
branches/gridsim4.0-branch3/source/gridsim/gui/DetachedMagnifyingGlass.java
branches/gridsim4.0-branch3/source/gridsim/gui/GridletPanel.java
Copied: branches/gridsim4.0-branch3/examples/examples/ar (from rev 53, trunk/examples/Example10)
Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java
===================================================================
--- trunk/examples/Example10/ARTest.java 2007-09-01 02:48:15 UTC (rev 53)
+++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -1,19 +1,24 @@
/*
- * Author Anthony Sulistio
- * Date: May 2004
+ * Author Marcos Dias de Assuncao
+ * Date: September 2007
* Description: A simple program to demonstrate of how to use basic
* advanced reservation functionalities, such as create, commit
* and status.
- *
- * NOTE: The values used from this example are taken from the GridSim paper.
- * http://www.gridbus.org/gridsim/
- * $Id: ARTest.java,v 1.3 2007/08/10 02:35:40 anthony Exp $
*/
-import java.util.*;
-import gridsim.*;
-import eduni.simjava.*;
+package examples.ar;
+import gridsim.GridSim;
+import gridsim.Gridlet;
+import gridsim.GridletList;
+import gridsim.turbo.Reservation;
+import gridsim.turbo.ReservationRequester;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.LinkedList;
+import java.util.Random;
+
/**
* A user entity that reserves a resource in advance.
* In this example, only explore some functionalities, such as:
@@ -23,11 +28,10 @@
* - commits an accepted reservation
* - checks the status of a reservation
*/
-public class ARTest extends AdvanceReservation
-{
+public class ARTest extends ReservationRequester {
private GridletList list_; // a list containing new Gridlets
private GridletList receiveList_; // a list containing completed Gridlets
- private int failReservation_; // number of reservations failed
+ private int failReservation_; // number of reservations failed
// time constant values
private final int SEC = 1; // 1 second
@@ -40,7 +44,6 @@
* Creates a new grid user entity
* @param name the Entity name of this object
* @param baud_rate the communication speed
- * @param timeZone user's local time zone
* @param totalJob number of Gridlets to be created
* @throws Exception This happens when creating this entity before
* initializing GridSim package or the entity name is
@@ -48,9 +51,8 @@
* @see gridsim.GridSim#init(int, Calendar, boolean)
*/
public ARTest(String name, double baud_rate, double timeZone,
- int totalJob) throws Exception
- {
- super(name, baud_rate, timeZone);
+ int totalJob) throws Exception {
+ super(name, baud_rate);
this.receiveList_ = new GridletList();
this.failReservation_ = 0;
@@ -65,8 +67,7 @@
/**
* The core method that handles communications among GridSim entities.
*/
- public void body()
- {
+ public void body() {
LinkedList resList;
// waiting to get list of resources. Since GridSim package uses
@@ -74,8 +75,7 @@
// before one or more grid resource entities manage to register
// themselves to GridInformationService (GIS) entity.
// Therefore, it's better to wait in the first place
- while (true)
- {
+ while (true) {
// need to pause for a while to wait GridResources finish
// registering to GIS
super.gridSimHold(2*SEC); // wait for 2 seconds
@@ -124,11 +124,10 @@
}
//----------------------------------------------------
- // sends one or more reservations to a gridresource entity
+ // sends one or more reservations to a grid resource entity
sendReservation(resARList, resNameList);
- try
- {
+ try {
// then get the results or Gridlets back
int size = list_.size() - failReservation_;
for (i = 0; i < size; i++)
@@ -154,23 +153,17 @@
* One reservation only reserves 1 PE. At the moment, GridSim is only
* able to execute 1 Gridlet on a single PE.
*/
- private void sendReservation(ArrayList resARList, ArrayList resNameList)
- {
+ private void sendReservation(ArrayList resARList, ArrayList resNameList) {
// total reservation made. 1 reservation reserves 1 PE.
- int totalPE = 1;
+ int totalPE = 2;
int totalReservation = list_.size(); // total number of Gridlets
- // gets the init simulation time
- Calendar cal = GridSim.getSimulationCalendar();
-
// wants to reserve 1 day after the init simulation time
- int MILLI_SEC = 1000;
- long time = cal.getTimeInMillis() + (1 * DAY * MILLI_SEC);
+ long time = 1 * DAY;
// each reservation requires around 10 minutes
int duration = 10 * MIN;
- String result = null;
Gridlet gl = null;
int val = 0;
int resID = 0; // a resource ID
@@ -179,8 +172,7 @@
Random randObj = new Random(time);
- for (int i = 0; i < totalReservation; i++)
- {
+ for (int i = 0; i < totalReservation; i++) {
duration += 5 * MIN; // duration of a reservation
// gets the resource ID and name
@@ -194,50 +186,38 @@
time = 0; // immediate reservation
}
else {
- time = cal.getTimeInMillis() + (1*DAY*MILLI_SEC)
- + (duration*MILLI_SEC);
+ time = 1 * HOUR + duration;
}
// creates a new or immediate reservation
- result = super.createReservation(time, duration, totalPE, resID);
- System.out.println(super.get_name() + ": reservation result from "+
- resName + " = " + result + " at time = " + GridSim.clock());
-
- // queries the status of this reservation
- val = super.queryReservation(result);
- System.out.println(super.get_name() + ": query result = " +
- AdvanceReservation.getQueryResult(val) );
+ Reservation reservation = null;
+ boolean success = false;
- // if a reservation fails, then continue the next Gridlet
- if (val == GridSimTags.AR_STATUS_ERROR ||
- val == GridSimTags.AR_STATUS_ERROR_INVALID_BOOKING_ID)
- {
+ reservation = super.createReservation(time, duration, totalPE, resID);
+ if(reservation != null) {
+ System.out.println(super.get_name() + ": reservation has been returned from "+
+ resName + " at time = " + GridSim.clock());
+ }
+ else {
+ System.out.println(super.get_name() + ": no reservation has been returned from "+
+ resName + " at time = " + GridSim.clock());
failReservation_++;
- System.out.println("==========================");
- continue;
}
- // for a reservation with an even number, commits straightaway
- // without sending any Gridlets yet
- if (i % 2 == 0)
- {
- val = super.commitReservation(result);
- System.out.println(super.get_name() +
- ": commit only with result = " +
- AdvanceReservation.getCommitResult(val) );
+ if(reservation != null) {
+ // for a reservation with an even number, commits straightaway
+ // without sending any Gridlets yet
+ success = super.commitReservation(reservation.getID());
+
+ if(success) {
+ System.out.println("Reservation # "+ reservation.getID() +
+ " has been committed successfully.");
+ }
+ else {
+ System.out.println("Reservation # "+ reservation.getID() +
+ " has NOT been committed successfully.");
+ }
}
-
- // a reservation only needs to reserve 1 PE.
- gl = (Gridlet) list_.get(i);
- val = super.commitReservation(result, gl);
- System.out.println(super.get_name() + ": commit result = " +
- AdvanceReservation.getCommitResult(val) );
-
- // queries the status of this reservation
- val = super.queryReservation(result);
- System.out.println(super.get_name() + ": query result = " +
- AdvanceReservation.getQueryResult(val) );
- System.out.println("==========================");
}
}
@@ -255,16 +235,15 @@
* GridSimRandom class.
* @return a GridletList object
*/
- private GridletList createGridlet(int size, int userID)
- {
+ private GridletList createGridlet(int size, int userID) {
// Creates a container to store Gridlets
GridletList list = new GridletList();
int length = 5000;
- for (int i = 0; i < size; i++)
- {
+ for (int i = 0; i < size; i++) {
// creates a new Gridlet object
Gridlet gridlet = new Gridlet(i, length, 1000, 5000);
+
// add the Gridlet into a list
list.add(gridlet);
gridlet.setUserID(userID);
Deleted: branches/gridsim4.0-branch3/examples/examples/ar/Example10.java
===================================================================
--- trunk/examples/Example10/Example10.java 2007-09-01 02:48:15 UTC (rev 53)
+++ branches/gridsim4.0-branch3/examples/examples/ar/Example10.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -1,263 +0,0 @@
-/*
- * Author Anthony Sulistio
- * Date: May 2004
- * Description: A simple program to demonstrate of how to use basic
- * advanced reservation functionalities, such as create, commit
- * and status.
- *
- * NOTE: The values used from this example are taken from the GridSim paper.
- * http://www.gridbus.org/gridsim/
- * $Id: Example10.java,v 1.2 2004/05/31 04:53:33 anthony Exp $
- */
-
-import java.util.*;
-import gridsim.*;
-
-/**
- * This is the main class to run the example.
- */
-public class Example10
-{
- /**
- * A main method that initializes GridSim, creating user and grid
- * resource entities before running the simulation.
- */
- public static void main(String[] args)
- {
- System.out.println("Starting Example10");
- try
- {
- // First step: Initialize the GridSim package. It should be called
- // before creating any entities. We can't run this example without
- // initializing GridSim first. We will get run-time exception
- // error.
- int num_user = 5; // number of user entities
-
- // Gets the current time as the init simulation time.
- // The time plays a very important role in determining start
- // and end time of a reservation. Both start and end time must
- // be greater than the init simulation time.
- Calendar calendar = Calendar.getInstance();
- System.out.println("Init simulation time = " + calendar.getTime());
-
- boolean trace_flag = false; // true means trace GridSim events
-
- // Since GridSim 3.0, there are different ways to initialize the
- // GridSim package. One of them is below without the need to
- // have GridStatistics entity. Therefore, removing any redundant
- // entities.
- GridSim.init(num_user, calendar, trace_flag);
-
- //------------------------------------------------
- // Second step: Creates one or more GridResource objects
- // given resource name, total PE, number of Machine, time zone
- // and MIPS Rating.
-
- // R0: vpac Compaq AlphaServer
- ARGridResource resource0 = createGridResource("Resource_0",
- 4, 1, 10.0, 515);
-
- // R1: Manjra Linux PC
- ARGridResource resource1 = createGridResource("Resource_1",
- 13, 1, 10.0, 684);
-
- // R2: Germany
- ARGridResource resource2 = createGridResource("Resource_2",
- 16, 1, 1.0, 410);
-
- // R3: Czech
- ARGridResource resource3 = createGridResource("Resource_3",
- 6, 1, 1.0, 410);
-
- // R4: Chichago
- ARGridResource resource4 = createGridResource("Resource_4",
- 8, 1, -6.0, 377);
-
- //------------------------------------------------
- // Third step: Creates grid users
- ARTest[] userList = new ARTest[num_user];
- ARTest user = null; // a user entity
- double bandwidth = 1000; // bandwidth of this user
- double timeZone = 0.0; // user's time zone
- int totalJob = 0; // total Gridlets owned
- int i = 0;
-
- // a loop that creates a user entity
- for (i = 0; i < num_user; i++)
- {
- // users with an even number have their time zone to GMT+8
- if (i % 2 == 0)
- {
- timeZone = 8.0; // with respect to GMT or UTC
- totalJob = 4;
- }
-
- // users with an odd number have their time zone to GMT-3
- else
- {
- timeZone = -3.0; // with respect to GMT or UTC
- totalJob = 5;
- }
-
- // creates a user entity
- user = new ARTest("User_" + i, bandwidth, timeZone, totalJob);
-
- // put the entity into an array
- userList[i] = user;
- }
-
- //------------------------------------------------
- // Fourth step: Starts the simulation
- GridSim.startGridSimulation();
-
- //------------------------------------------------
- // Final step: Prints the Gridlets when this simulation is over
- GridletList newList = null;
- for (i = 0; i < num_user; i++)
- {
- user = (ARTest) userList[i];
- newList = user.getGridletList();
- printGridletList( newList, user.get_name() );
- }
-
- System.out.println("Finish Example10");
- }
- catch (Exception e)
- {
- System.out.println("Error ...... EXCEPTION");
- e.printStackTrace();
- }
-
- }
-
- /**
- * Creates a GridResource entity that supports advanced reservation
- * functionalities.
- */
- private static ARGridResource createGridResource(String name, int totalPE,
- int totalMachine, double timeZone, int rating)
- {
- // Here are the steps needed to create a Grid resource:
- // 1. We need to create an object of MachineList to store one or more
- // Machines
- MachineList mList = new MachineList();
- for (int i = 0; i < totalMachine; i++)
- {
- // 2. A Machine contains one or more PEs or CPUs. Therefore, should
- // create an object of PEList to store these PEs before creating
- // a Machine.
- PEList peList = new PEList();
-
- // 3. Create PEs and add these into an object of PEList.
- for (int k = 0; k < totalPE; k++)
- {
- // need to store PE id and MIPS Rating
- peList.add( new PE(k, rating) );
- }
-
- // 4. Create one Machine with its id and list of PEs or CPUs
- mList.add( new Machine(i, peList) );
- }
-
- // 5. Create a ResourceCharacteristics object that stores the
- // properties of a Grid resource: architecture, OS, list of
- // Machines, allocation policy, time zone and its price
- String arch = "Sun Ultra"; // system architecture
- String os = "Solaris"; // operating system
- double cost = 3.0; // the cost of using this resource (G$/PE)
-
- // NOTE: allocation policy in here is set to
- // ResourceCharacteristics.ADVANCE_RESERVATION not SPACE_SHARED nor
- // TIME_SHARED.
- ResourceCharacteristics resConfig = new ResourceCharacteristics(
- arch, os, mList, ResourceCharacteristics.ADVANCE_RESERVATION,
- timeZone, cost);
-
- // 6. Finally, we need to create a GridResource object.
- double baud_rate = 1000.0; // communication speed
- long seed = 11L*13*17*19*23+1;
- double peakLoad = 0.0; // the resource load during peak hour
- double offPeakLoad = 0.0; // the resource load during off-peak hr
- double holidayLoad = 0.0; // the resource load during holiday
-
- // incorporates weekends so the grid resource is on 7 days a week
- LinkedList Weekends = new LinkedList();
- Weekends.add(new Integer(Calendar.SATURDAY));
- Weekends.add(new Integer(Calendar.SUNDAY));
-
- // incorporates holidays. However, no holidays are set in this example
- LinkedList Holidays = new LinkedList();
- ARGridResource gridRes = null;
-
- // creates a resource calendar that handles different loads
- ResourceCalendar cal = new ResourceCalendar(
- resConfig.getResourceTimeZone(), peakLoad, offPeakLoad,
- holidayLoad, Weekends, Holidays, seed);
-
- try
- {
- // use this AR scheduling algorithm. The name of this entity
- // will be name_scheduler, e.g. Resource0_scheduler.
- String scheduler = "scheduler";
- ARSimpleSpaceShared policy =new ARSimpleSpaceShared(name,scheduler);
-
- // then creates a grid resource entity.
- // NOTE: You need to use a grid resource entity that supports
- // advanced reservation functionalities. In this case, the entity
- // is called ARGridResource.
- gridRes = new ARGridResource(name,baud_rate,resConfig,cal,policy);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
-
- System.out.println("Creates one Grid resource with name = " + name);
- return gridRes;
- }
-
- /**
- * Prints the Gridlet objects
- * @param list list of Gridlets
- */
- private static void printGridletList(GridletList list, String name)
- {
- String indent = " ";
- System.out.println();
- System.out.println("========== OUTPUT for " + name + " ==========");
- System.out.println("Gridlet ID" + indent + "STATUS" + indent +
- "Resource ID" + indent + "Cost");
-
- int size = list.size();
- int i = 0;
- Gridlet gridlet = null;
- String status;
-
- // for each user entity, prints out the results. Prints out the
- // table of summary
- for (i = 0; i < size; i++)
- {
- gridlet = (Gridlet) list.get(i);
- System.out.print(indent + gridlet.getGridletID() + indent
- + indent);
-
- status = gridlet.getGridletStatusString();
- System.out.print(status);
-
- System.out.println( indent + indent + gridlet.getResourceID() +
- indent + indent + gridlet.getProcessingCost() );
- }
-
- // for each Gridlet, prints out its detailed operation / report
- /***** NOTE: Not recommended for many Gridlets as each Gridlet
- // report is pretty long
- System.out.println();
- for (i = 0; i < size; i++)
- {
- gridlet = (Gridlet) list.get(i);
- System.out.println( gridlet.getGridletHistory() );
- }
- *********/
- }
-
-} // end class
-
Deleted: branches/gridsim4.0-branch3/examples/examples/ar/README.txt
===================================================================
--- trunk/examples/Example10/README.txt 2007-09-01 02:48:15 UTC (rev 53)
+++ branches/gridsim4.0-branch3/examples/examples/ar/README.txt 2007-10-04 06:03:39 UTC (rev 64)
@@ -1,47 +0,0 @@
-
-/**
- * Author: Anthony Sulistio
- * Date: May 2004
- * $Id: README.txt,v 1.4 2007/08/10 02:35:23 anthony Exp $
- */
-
-Welcome to the 10th Example of how to use GridSim package.
-To compile the example source code:
- In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. Example10.java
- In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. Example10.java
-
-where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package.
-
-
-To run the class file:
- In Unix/Linux:
- java -classpath $GRIDSIM/jars/gridsim.jar:. Example10
-
- In Windows:
- java -classpath %GRIDSIM%\jars\gridsim.jar;. Example10
-
-
-NOTE: This example uses Java Random class to select a resource entity to
- process a Gridlet. Hence, when running this example many times,
- the values are different.
-
-
-When running the example file, it will produce the following files:
-
- tracefile -> created by SimJava 1.2, now being replaced by sim_trace
- NOTE: GridSim 2.1 uses SimJava 1.2 package
- GridSim 2.2 onwards use SimJava2 package
-
- sim_trace -> created by the SimJava2 package (lower-level) to trace every
- events (performed by SimJava and GridSim) during the simulation.
- We don't need to worry about this file. Not to important for our
- example.
-
- sim_report -> created by the SimJava2 package (lower-level) of GridSim.
- This is a simulation report that contains general information about
- running this experiment. We don't need to worry about this file.
- Not to important for our example.
-
-NOTE: When you run the program multiple times,
- "sim_trace" and "sim_report" file will be overwritten.
-
Added: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java (rev 0)
+++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -0,0 +1,245 @@
+/*
+ * Author: Marcos Dias de Assuncao
+ * Date: September 2007
+ * Description: A simple program to demonstrate of how to use basic
+ * advanced reservation functionalities, such as create, commit
+ * and status.
+ */
+
+package examples.ar;
+
+import java.util.*;
+import gridsim.*;
+import gridsim.turbo.ARParallelSpaceShared;
+import gridsim.turbo.ARTGridResource;
+import gridsim.turbo.TResourceCharacteristics;
+
+/**
+ * This is the main class to run the example.
+ */
+public class SimpleARExample01 {
+
+ /**
+ * A main method that initialises GridSim, creating user and grid
+ * resource entities before running the simulation.
+ */
+ public static void main(String[] args) {
+ System.out.println("SimpleARExample01");
+ try {
+ // First step: Initialises the GridSim package. It should be called
+ // before creating any entities. We can't run this example without
+ // initialising GridSim first. We will get run-time exception
+ // error.
+ int num_user = 1; // number of user entities
+
+ // Gets the current time as the init simulation time.
+ // The time plays a very important role in determining start
+ // and end time of a reservation. Both start and end time must
+ // be greater than the init simulation time.
+ Calendar calendar = Calendar.getInstance();
+ System.out.println("Init simulation time = " + calendar.getTime());
+
+ boolean trace_flag = false; // true means trace GridSim events
+
+ // Since GridSim 3.0, there are different ways to initialize the
+ // GridSim package. One of them is below without the need to
+ // have GridStatistics entity. Therefore, removing any redundant
+ // entities.
+ GridSim.init(num_user, calendar, trace_flag);
+
+ //------------------------------------------------
+ // Second step: Creates one or more GridResource objects
+ // given resource name, total PE, number of Machine, time zone
+ // and MIPS Rating.
+
+// // R0: vpac Compaq AlphaServer
+// ARTGridResource resource0 =
+// createGridResource("Resource_0", 4, 1, 10.0, 515);
+
+ // R1: Manjra Linux PC
+ ARTGridResource resource1 =
+ createGridResource("Resource_1", 13, 1, 10.0, 684);
+
+// // R2: Germany
+// ARTGridResource resource2 =
+// createGridResource("Resource_2", 16, 1, 1.0, 410);
+//
+// // R3: Czech
+// ARTGridResource resource3 =
+// createGridResource("Resource_3", 6, 1, 1.0, 410);
+//
+// // R4: Chichago
+// ARTGridResource resource4 =
+// createGridResource("Resource_4", 8, 1, -6.0, 377);
+
+ //------------------------------------------------
+ // Third step: Creates grid users
+ ARTest[] userList = new ARTest[num_user];
+ ARTest user = null; // a user entity
+ double bandwidth = 1000; // bandwidth of this user
+ double timeZone = 0.0; // user's time zone
+ int totalJob = 0; // total Gridlets owned
+ int i = 0;
+
+ // a loop that creates a user entity
+ for (i = 0; i < num_user; i++) {
+ // users with an even number have their time zone to GMT+8
+ if (i % 2 == 0) {
+ timeZone = 8.0; // with respect to GMT or UTC
+ totalJob = 4;
+ }
+
+ // users with an odd number have their time zone to GMT-3
+ else {
+ timeZone = -3.0; // with respect to GMT or UTC
+ totalJob = 5;
+ }
+
+ // creates a user entity
+ user = new ARTest("User_" + i, bandwidth, timeZone, totalJob);
+
+ // put the entity into an array
+ userList[i] = user;
+ }
+
+ //------------------------------------------------
+ // Fourth step: Starts the simulation
+// GridSim.startGridSimulation();
+
+ GridSim.startGridSimulation(true);
+
+ //------------------------------------------------
+ // Final step: Prints the Gridlets when this simulation is over
+ GridletList newList = null;
+ for (i = 0; i < num_user; i++) {
+ user = (ARTest) userList[i];
+ newList = user.getGridletList();
+ printGridletList( newList, user.get_name() );
+ }
+
+ System.out.println("Finish SimpleARExample01");
+ }
+ catch (Exception e) {
+ System.out.println("Error ...... EXCEPTION");
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Creates a GridResource entity that supports advanced reservation
+ * functionalities.
+ */
+ private static ARTGridResource createGridResource(String name, int totalPE,
+ int totalMachine, double timeZone, int rating) {
+ // Here are the steps needed to create a Grid resource:
+ // 1. We need to create an object of MachineList to store one or more
+ // Machines
+
+ MachineList mList = new MachineList();
+
+ for (int i = 0; i < totalMachine; i++) {
+ //////////////////////////////////////////
+ // 4. Create one Machine with its id and list of PEs or CPUs
+ mList.add( new Machine(i, totalPE, rating) );
+ }
+
+ // 2. Create a TResourceCharacteristics object that stores the
+ // properties of a Grid resource: architecture, OS, list of
+ // Machines, allocation policy, time zone and its price
+ String arch = "Sun Ultra"; // system architecture
+ String os = "Solaris"; // operating system
+ double cost = 3.0; // the cost of using this resource (G$/PE)
+
+ // NOTE: allocation policy in here is set to
+ // TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED not SPACE_SHARED nor
+ // TIME_SHARED.
+ TResourceCharacteristics resConfig = new TResourceCharacteristics(
+ arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED,
+ timeZone, cost);
+
+ // 6. Finally, we need to create a GridResource object.
+ double baud_rate = 1000.0; // communication speed
+ long seed = 11L*13*17*19*23+1;
+ double peakLoad = 0.0; // the resource load during peak hour
+ double offPeakLoad = 0.0; // the resource load during off-peak hr
+ double holidayLoad = 0.0; // the resource load during holiday
+
+ // incorporates weekends so the grid resource is on 7 days a week
+ LinkedList Weekends = new LinkedList();
+ Weekends.add(new Integer(Calendar.SATURDAY));
+ Weekends.add(new Integer(Calendar.SUNDAY));
+
+ // incorporates holidays. However, no holidays are set in this example
+ LinkedList Holidays = new LinkedList();
+ ARTGridResource gridRes = null;
+
+ // creates a resource calendar that handles different loads
+ ResourceCalendar cal = new ResourceCalendar(
+ resConfig.getResourceTimeZone(), peakLoad, offPeakLoad,
+ holidayLoad, Weekends, Holidays, seed);
+
+ try {
+ // use this AR scheduling algorithm. The name of this entity
+ // will be name_scheduler, e.g. Resource0_scheduler.
+ String scheduler = "scheduler";
+ ARParallelSpaceShared policy = new ARParallelSpaceShared(name, scheduler);
+
+ // then creates a grid resource entity.
+ // NOTE: You need to use a grid resource entity that supports
+ // advanced reservation functionalities. In this case, the entity
+ // is called ARGridResource.
+ gridRes = new ARTGridResource(name,baud_rate,resConfig,cal,policy);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Creates one Grid resource with name = " + name);
+ return gridRes;
+ }
+
+ /**
+ * Prints the Gridlet objects
+ * @param list list of Gridlets
+ */
+ private static void printGridletList(GridletList list, String name) {
+ String indent = " ";
+ System.out.println();
+ System.out.println("========== OUTPUT for " + name + " ==========");
+ System.out.println("Gridlet ID" + indent + "STATUS" + indent +
+ "Resource ID" + indent + "Cost");
+
+ int size = list.size();
+ int i = 0;
+ Gridlet gridlet = null;
+ String status;
+
+ // for each user entity, prints out the results. Prints out the
+ // table of summary
+ for (i = 0; i < size; i++) {
+ gridlet = (Gridlet) list.get(i);
+ System.out.print(indent + gridlet.getGridletID() + indent
+ + indent);
+
+ status = gridlet.getGridletStatusString();
+ System.out.print(status);
+
+ System.out.println( indent + indent + gridlet.getResourceID() +
+ indent + indent + gridlet.getProcessingCost() );
+ }
+
+ // for each Gridlet, prints out its detailed operation / report
+ /***** NOTE: Not recommended for many Gridlets as each Gridlet
+ // report is pretty long
+ System.out.println();
+ for (i = 0; i < size; i++)
+ {
+ gridlet = (Gridlet) list.get(i);
+ System.out.println( gridlet.getGridletHistory() );
+ }
+ *********/
+ }
+
+} // end class
+
Added: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java (rev 0)
+++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -0,0 +1,179 @@
+
+package examples.workload.ar;
+
+import gridsim.GridResource;
+import gridsim.GridSim;
+import gridsim.Machine;
+import gridsim.MachineList;
+import gridsim.ResourceCalendar;
+import gridsim.turbo.ARTGridResource;
+import gridsim.turbo.TResourceCharacteristics;
+import gridsim.util.Workload;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.LinkedList;
+import java.util.Random;
+
+
+/**
+ * Test Driver class for this example
+ */
+public class TurboARExample01
+{
+ /**
+ * Creates main() to run this example
+ */
+ public static void main(String[] args)
+ {
+ long startTime = System.currentTimeMillis();
+ if(args.length == 0){
+ System.out.println("Please provide the location of the workload file!");
+ System.exit(1);
+ }
+
+ try {
+
+ //////////////////////////////////////////
+ // Get the workload to be used The format should be:
+ // ASCII text, gzip or zip.
+
+ String fileName = args[0];
+ // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf
+
+ ArrayList<GridResource> resources = new ArrayList<GridResource>();
+
+ //////////////////////////////////////////
+ // Initialize the GridSim package. It should be called
+ // before creating any entities. We can't run this example without
+ // initializing GridSim first. We will get run-time exception
+ // error.
+
+ // number of grid user entities + any Workload entities.
+ int num_user = 1;
+ Calendar calendar = Calendar.getInstance();
+ boolean trace_flag = false; // mean trace GridSim events
+
+ // Initialize the GridSim package without any statistical
+ // functionalities. Hence, no GridSim_stat.txt file is created.
+ System.out.println("Initializing GridSim package");
+ GridSim.init(num_user, calendar, trace_flag);
+
+ //////////////////////////////////////////
+ // Creates one or more GridResource entities
+ int totalResource = 1; // total number of Grid resources
+ int rating = 377; // rating of each PE in MIPS
+ int totalPE = 9; // total number of PEs for each Machine
+ int totalMachine = 128; // total number of Machines
+ int i = 0;
+
+ String[] resArray = new String[totalResource];
+ for (i = 0; i < totalResource; i++)
+ {
+ String resName = "Res_" + i;
+ GridResource resource = createGridResource(resName, rating, totalMachine, totalPE);
+ resources.add(resource);
+
+ // add a resource name into an array
+ resArray[i] = resName;
+ }
+
+ //////////////////////////////////////////
+ // Creates one Workload trace entity.
+
+ int resID = 0;
+ Random r = new Random();
+ resID = r.nextInt(totalResource);
+ Workload workload = new Workload("Load_1", fileName, resArray[resID], rating);
+
+ //////////////////////////////////////////
+ // Starts the simulation in debug mode
+ GridSim.startGridSimulation(true);
+
+ // Start the simulation in normal mode
+// GridSim.startGridSimulation();
+
+ //////////////////////////////////////////
+ // Final step: Prints the Gridlets when simulation is over
+ long finishTime = System.currentTimeMillis();
+ System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds");
+
+ // prints the Gridlets inside a Workload entity
+ // workload.printGridletList(trace_flag);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates one Grid resource. A Grid resource contains one or more
+ * Machines. Similarly, a Machine contains one or more PEs (Processing
+ * Elements or CPUs).
+ * @param name a Grid Resource name
+ * @param peRating rating of each PE
+ * @param totalMachine total number of Machines
+ * @param totalPE total number of PEs for each Machine
+ */
+ private static GridResource createGridResource(String name, int peRating,
+ int totalMachine, int totalPE)
+ {
+
+ //////////////////////////////////////////
+ // Here are the steps needed to create a Grid resource:
+ // 1. We need to create an object of MachineList to store one or more
+ // Machines
+ MachineList mList = new MachineList();
+
+ for (int i = 0; i < totalMachine; i++)
+ {
+ //////////////////////////////////////////
+ // 4. Create one Machine with its id and list of PEs or CPUs
+ mList.add( new Machine(i, totalPE, peRating) );
+ }
+
+ //////////////////////////////////////////
+ // 5. Create a ResourceCharacteristics object that stores the
+ // properties of a Grid resource: architecture, OS, list of
+ // Machines, allocation policy: time- or space-shared, time zone
+ // and its price (G$/PE time unit).
+ String arch = "Sun Ultra"; // system architecture
+ String os = "Solaris"; // operating system
+ double time_zone = 0.0; // time zone this resource located
+ double cost = 3.0; // the cost of using this resource
+
+ TResourceCharacteristics resConfig = new TResourceCharacteristics(
+ arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED,
+ time_zone, cost);
+
+ //////////////////////////////////////////
+ // 6. Finally, we need to create a GridResource object.
+ double baud_rate = 10000.0; // communication speed
+ long seed = 11L*13*17*19*23+1;
+ double peakLoad = 0.0; // the resource load during peak hour
+ double offPeakLoad = 0.0; // the resource load during off-peak hr
+ double holidayLoad = 0.0; // the resource load during holiday
+
+ // incorporates weekends so the grid resource is on 7 days a week
+ LinkedList weekends = new LinkedList();
+ weekends.add(new Integer(Calendar.SATURDAY));
+ weekends.add(new Integer(Calendar.SUNDAY));
+
+ // incorporates holidays. However, no holidays are set in this example
+ LinkedList holidays = new LinkedList();
+ ResourceCalendar calendar = new ResourceCalendar(time_zone, peakLoad,
+ offPeakLoad, holidayLoad, weekends, holidays, seed);
+
+ ARTGridResource gridRes = null;
+ try {
+ gridRes = new ARTGridResource(name, baud_rate, resConfig, calendar, null);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Creates one Grid resource with name = " + name);
+ return gridRes;
+ }
+} // end class
+
Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-09-22 22:44:03 UTC (rev 63)
+++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -5,7 +5,7 @@
import gridsim.GridSim;
import gridsim.Machine;
import gridsim.MachineList;
-import gridsim.ResourceCharacteristics;
+import gridsim.turbo.TResourceCharacteristics;
import gridsim.util.Workload;
import java.util.ArrayList;
@@ -66,8 +66,7 @@
int i = 0;
String[] resArray = new String[totalResource];
- for (i = 0; i < totalResource; i++)
- {
+ for (i = 0; i < totalResource; i++) {
String resName = "Res_" + i;
GridResource resource = createGridResource(resName, rating, totalMachine, totalPE);
resources.add(resource);
@@ -86,10 +85,10 @@
//////////////////////////////////////////
// Starts the simulation in debug mode
-// GridSim.startGridSimulation(true);
+ GridSim.startGridSimulation(true);
// Start the simulation in normal mode
- GridSim.startGridSimulation();
+// GridSim.startGridSimulation();
//////////////////////////////////////////
// Final step: Prints the Gridlets when simulation is over
@@ -140,8 +139,8 @@
double time_zone = 0.0; // time zone this resource located
double cost = 3.0; // the cost of using this resource
- ResourceCharacteristics resConfig = new ResourceCharacteristics(
- arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED,
+ TResourceCharacteristics resConfig = new TResourceCharacteristics(
+ arch, os, mList, TResourceCharacteristics.PARALLEL_SPACE_SHARED,
time_zone, cost);
//////////////////////////////////////////
@@ -153,17 +152,17 @@
double holidayLoad = 0.0; // the resource load during holiday
// incorporates weekends so the grid resource is on 7 days a week
- LinkedList Weekends = new LinkedList();
- Weekends.add(new Integer(Calendar.SATURDAY));
- Weekends.add(new Integer(Calendar.SUNDAY));
+ LinkedList weekends = new LinkedList();
+ weekends.add(new Integer(Calendar.SATURDAY));
+ weekends.add(new Integer(Calendar.SUNDAY));
// incorporates holidays. However, no holidays are set in this example
- LinkedList Holidays = new LinkedList();
+ LinkedList holidays = new LinkedList();
GridResource gridRes = null;
try {
gridRes = new GridResource(name, baud_rate, seed,
- resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends,
- Holidays);
+ resConfig, peakLoad, offPeakLoad, holidayLoad, weekends,
+ holidays);
}
catch (Exception e) {
e.printStackTrace();
Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2007-09-22 22:44:03 UTC (rev 63)
+++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -5,7 +5,7 @@
import gridsim.GridSim;
import gridsim.Machine;
import gridsim.MachineList;
-import gridsim.ResourceCharacteristics;
+import gridsim.turbo.TResourceCharacteristics;
import java.util.ArrayList;
import java.util.Calendar;
@@ -137,8 +137,8 @@
double time_zone = 0.0; // time zone this resource located
double cost = 3.0; // the cost of using this resource
- ResourceCharacteristics resConfig = new ResourceCharacteristics(
- arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED,
+ TResourceCharacteristics resConfig = new TResourceCharacteristics(
+ arch, os, mList, TResourceCharacteristics.PARALLEL_SPACE_SHARED,
time_zone, cost);
//////////////////////////////////////////
@@ -150,17 +150,17 @@
double holidayLoad = 0.0; // the resource load during holiday
// incorporates weekends so the grid resource is on 7 days a week
- LinkedList Weekends = new LinkedList();
- Weekends.add(new Integer(Calendar.SATURDAY));
- Weekends.add(new Integer(Calendar.SUNDAY));
+ LinkedList weekends = new LinkedList();
+ weekends.add(new Integer(Calendar.SATURDAY));
+ weekends.add(new Integer(Calendar.SUNDAY));
// incorporates holidays. However, no holidays are set in this example
- LinkedList Holidays = new LinkedList();
+ LinkedList holidays = new LinkedList();
GridResource gridRes = null;
try {
gridRes = new GridResource(name, baud_rate, seed,
- resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends,
- Holidays);
+ resConfig, peakLoad, offPeakLoad, holidayLoad, weekends,
+ holidays);
}
catch (Exception e) {
e.printStackTrace();
Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java 2007-09-22 22:44:03 UTC (rev 63)
+++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -18,7 +18,7 @@
import java.util.ArrayList;
/**
- * This class is an extended version of @link{Workload}. This class
+ * This class is an extended version of {@link Workload}. This class
* cancels some gridlets submitted.
*
* @author Marcos Dias de Assuncao
@@ -33,7 +33,7 @@
private final double TIME_CANCELLATION = 0.5;
/**
- * Create a new @link{WorkloadWithCancellation} object <b>without</b> using
+ * Create a new {@link WorkloadWithCancellation} object <b>without</b> using
* the network extension. This means this entity directly sends Gridlets
* to a resource destination without going through a wired network. <br>
* <tt>NOTE:</tt>
@@ -68,7 +68,7 @@
}
/**
- * Create a new @link{WorkloadWithCancellation} object <b>with</b> the network extension.
+ * Create a new {@link WorkloadWithCancellation} object <b>with</b> the network extension.
* This means this entity directly sends Gridlets to a destination resource
* through a link. The link is automatically created by this constructor.
*
@@ -182,12 +182,12 @@
if (data != null && data instanceof Gridlet) {
gl = (Gridlet) data;
- if(gl.getGridletStatus() == Gridlet.FAILED)
- System.out.println("Gridlet failed");
+// if(gl.getGridletStatus() == Gridlet.FAILED)
+// System.out.println("Gridlet failed");
+//
+// if(gl.getGridletStatus() == Gridlet.CANCELED)
+// System.out.println("Gridlet cancelled");
- if(gl.getGridletStatus() == Gridlet.CANCELED)
- System.out.println("Gridlet cancelled");
-
list_.add(gl);
counter++;
}
Deleted: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java 2007-09-22 22:44:03 UTC (rev 63)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -1,134 +0,0 @@
-/* Sim_accum.java */
-
-package eduni.simjava;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A class for collecting basic statistical data during simulations.
- * <p>
- * This class can be used to manually calculate measurements of
- * interest for state-based, non-continuous measures (see the
- * <a href="http://www.dcs.ed.ac.uk/home/simjava/tutorial/index.html#6">SimJava Tutorial</a> for details).
- * This is a primitive class that is still present in the API for compatibility with existing
- * simulations. Simulations written with the SimJava version 2.0 should make use of <code>Sim_stat</code>
- * instances for their entities if statistics are required.
- * @see eduni.simjava.Sim_stat
- * @version 1.0, 4 September 1996
- * @version 1.1, 29 May 1997 fwh corrected update() bug.
- * @author Ross McNab
- */
-public class Sim_accum {
- private List intervals;
- private List values;
-
- /**
- * Allocate a new instance of the class.
- */
- public Sim_accum() {
- intervals = new ArrayList();
- values = new ArrayList();
- }
-
- /**
- * Allocate a new, named, instance of the class. The name is
- * supplied for <code>SIM++</code> compatibility.
- * @param name The name to be associated with the instance (currently ignored)
- */
- public Sim_accum(String name) { // For SIM++ compatibility
- new Sim_accum();
- }
-
- /**
- * Add a new record to the statistics collected so far.
- * @param interval How long the value was held
- * @param value The value to record
- */
- public void update(double interval, double value) {
- intervals.add(new Double(interval));
- values.add(new Double(value));
- }
-
- /**
- * Find the minimum value recorded so far
- * @return The minimum value recorded so far or 0.0 if no values have been recorded
- */
- public double min(){
- double ret, val;
- if (intervals.size() == 0)
- ret = 0.0;
- else {
- ret = ((Double)values.get(0)).doubleValue();
- int values_size = values.size();
- for (int i=0; i < values_size; i++) {
- val = ((Double)values.get(i)).doubleValue();
- if (val<ret) ret = val;
- }
- }
- return ret;
- }
-
-
- /**
- * Find the maximum value recorded so far
- * @return The maximum value recorded so far or 0.0 if no values have been recorded
- */
- public double max() {
- double ret, val;
- if (intervals.size() == 0)
- ret = 0.0;
- else {
- ret = ((Double)values.get(0)).doubleValue();
- int values_size = values.size();
- for (int i=0; i < values_size; i++) {
- val = ((Double)values.get(i)).doubleValue();
- if (val>ret) ret = val;
- }
- }
- return ret;
- }
-
- /**
- * Calculates the average value held over the total
- * interval recorded.
- * i.e. <code>Sum_for_all_i(value[i]*interval[i])/total_interval</code>
- * @return The average value
- */
- public double avg() {
- double ret, val, inter;
- if (intervals.size() == 0)
- ret = 0.0;
- else {
- ret = 0.0;
- int intervals_size = intervals.size();
- for (int i=0; i < intervals_size; i++) {
- val = ((Double)values.get(i)).doubleValue();
- inter = ((Double)intervals.get(i)).doubleValue();
- ret += val * inter;
- }
- ret = ret / interval_sum();
- }
- return ret;
- }
-
- /**
- * Sums all the intervals recorded so far.
- * @return The sum of the intervals
- */
- public double interval_sum() {
- double ret, val;
- if (intervals.size() == 0)
- ret = 0.0;
- else {
- ret = 0.0;
- int intervals_size = intervals.size();
- for (int i=0; i < intervals_size; i++) {
- val = ((Double)intervals.get(i)).doubleValue();
- ret += val;
- }
- }
- return ret;
- }
-}
-
Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2007-09-22 22:44:03 UTC (rev 63)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2007-10-04 06:03:39 UTC (rev 64)
@@ -14,8 +14,6 @@
* behaviour. Methods beginning with the prefix <code>sim_</code> are runtime
* methods to be called within <code>body()</code>.
* <p>
- * Since version 2.0, entities don't need to check transient or termination
- * conditions. These are all maintained and checked by <code>Sim_system</code>.
* To check whether the termination condition has been satisfied, entities
* should use the <code>Sim_system.running()</code> method. As such. entities
* that exhibit a continuous, looping behaviour should have a <code>body()</code>
@@ -54,79 +52,12 @@
* when the entity is considered to be busy processing.
* </ul>
* <p>
- * In order to collect statistical measurements from entities a <code>Sim_stat</code> object needs
- * to be defined for the entity. This is the object in charge of collecting observations and
- * calculating measurements. Measures of interest could be default of custom. Default measures are
- * those which can be considered in most simulations and whose update can be automatically carried
- * out without user effort. Custom measures on the other hand...
[truncated message content] |