Hello this question definite falls under Advanced. I've created the code to to the following. Its actually 3 classes of code. Any help would be appreciated.
here what it does and hereare the problems am having with it. Thanks again for reading:
Explanation of code
This code is for Discrete Event Simulation Techniques. The code written creates a number of classes. Mainly it has the classes MS1 , MS2 and BTS1 and BTS2,
MS1 sends signals to BTS1 and MS2 sends signals to BTS2. MS1and BTS1 has no connection to MS2 and MTS2.
How does signals go from MS1 to BTS1? It sends the signals to the class Signals. Signals then sends the signals o the class Queue which is like a cable or line in real life. Hence a cable called queueMStoBTS which is an object of class Queue connects MS1 and BTS1.
Now the for MS2 and BTS2 the same thing happens. Except the class Signals is replaced by SignalsMS2 and Queue is replaced by class QueueMS2 and its object is queueMS2toBTS2.
Now the only connection between MS1/BTS1 and MS2/BTS2 is that when the simulation is being performed signals running from MS1 to BTS1 and from MS2 toBTS2 occurs in parallel ( at the same time).
Now the Simulation is performed for 610 time units. And every 10 time units a sample of the amount of bytes ( signals are measured in bytes ) flowing through each queue is measured and that value is put into an array which stores the value. This is done for both MS1/BTS1 and MS2.BTS2.
In the end a graph is plotted with bytes at each 10 units time VS time.
Hence am suppose to get 2 graphs at the end. One for MS1/BTS1 and MS2/BTs2.
My problem is that the simulation does not run for the full 610 time units. It stop sometimes at 3 units. And the only time the graphs can be printed is when the time unit exceeds 600 time units and since the time units never exceeds 600 the graphs are never plotted.
Could you give it a look please. I worked really hard on this one.
Thanks? Avin And here are the classes..remember its three classes..
/*------------MOBILE STATION ONE------------------------------------*/ /*This class generates signals and puts it in the Signals Class. The Signals class then puts it into the Queue. And the Queue then transports these signals to the BTS1 class. This code is an extension of the "Build a Discete Event Simulation Class MS2 is a basic replica of this class.
in Ten Easy Steps.. thats why it looks familar. */
class MS1 extends Event { private Vector msSignals = new Vector();
class DynamicArray { static private int i ; static private int l; static private int data[] = new int[1]; static private int data1[] = new int[1]; static private int newdata[]; static private int newdata1[]; static private int k=0; static private int q=0; static private int newSize; static private int newSize1;
public DynamicArray(){}
static void arrayMethod(int j) { i = j ; if(k==data.length) { newSize = data.length +1; int[] newData = new int[newSize];
class DynamicArray2 { static private int i ; static private int l; static private int data[] = new int[1]; static private int data1[] = new int[1]; static private int newdata[]; static private int newdata1[]; static private int k=0; static private int q=0; static private int newSize; static private int newSize1;
public DynamicArray2(){}
static void arrayMethod(int j) { i = j ; if(k==data.length) { newSize = data.length +1; int[] newData = new int[newSize];
/*---------------------DESim ADD GRAPH-------------------*/ /*This class takes the values stored in the Dynamic Arrays makes a point to point graph out of them. */
class DESimGraph { private int[] data ; private int[] data1;
public DESimGraph(int[] dataEx , int[] data1Ex) { data = dataEx ; data1 = data1Ex;
Plot plot = new Plot(data , data1);
plot.setLayout(null); JFrame frame = new JFrame(); frame.setBackground(Color.white);
Nowhere in the code you posted is there a class called AbstractSimulator although you call it several places. That was the first problem I encountered trying to compile it. Without that no one can help.
abstract class OrderedSet { abstract void insert(Comparable x); abstract Comparable removeFirst(); abstract int size(); }
class AbstractSimulator { OrderedSet events; void insert(AbstractEvent e) { events.insert(e); } AbstractEvent cancel(AbstractEvent e) { throw new java.lang.RuntimeException("Method not implemented"); } }
abstract class Event extends AbstractEvent { double time; public boolean lessThan(Comparable y) { Event e = (Event) y; // Will throw an exception if y is not an Event return this.time < e.time; } }
Hello I just wante dto metion that this simulation deals with a Celluar System. It is suppose to simulate the amount of bytes moveing from Two Mobile Stations to two Base Station Transmitters in parallel.
Just to mention it, if you want your code to be formatted and syntax highlighted when you post to this forum, surround it with java and /java in square brackets. See an example on: