Ahmad Tarraf
Ahmad Tarraf

Reputation: 89

Exception in thread "main" java.lang.NoClassDefFoundError on ssj-2.5.jar library

I have a problem running this java code that simulates the work of a CPU.It serves processes using round robin method . I got the code from a reference and it is exactly what i need but unfortunately its not running and throws this exception :

Exception in thread "main" java.lang.NoClassDefFoundError: optimization/Lmder_fcn
    at umontreal.iro.lecuyer.probdist.StudentDist.inverseF(StudentDist.java:278)
    at umontreal.iro.lecuyer.stat.Tally.confidenceIntervalStudent(Tally.java:294)
    at umontreal.iro.lecuyer.stat.Tally.formatCIStudent(Tally.java:359)
    at umontreal.iro.lecuyer.stat.Tally.report(Tally.java:497)

here is the code :

package timeshared;
import umontreal.iro.lecuyer.simevents.*;
import umontreal.iro.lecuyer.simprocs.*;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.randvar.*;
import umontreal.iro.lecuyer.stat.Tally;
import java.io.*;


public class RoundRobinQueue {
    int NumberOfTermainals = 20; // Number of terminals.
    double q; // Quantum size.
    double overhead = 0.001; // Amount of overhead (h).
    double meanThinkingTime = 5.0; // Mean thinking time.
    double alpha = 0.5; // Parameters of the Weibull service times.
    double lambda = 1.0; // ''
    double delta = 0.0; // ''
    int N = 1100; // Total number of tasks to simulate.
    int N0 = 100; // Number of tasks for warmup.
    int NumberOfTasks; // Number of tasks ended so far.
    RandomStream streamThink = new MRG32k3a();
    RandomVariateGen genThink = new ExponentialGen(streamThink, 1.0 / meanThinkingTime);
    RandomStream streamServ = new MRG32k3a("Gen. for service requirements");
    RandomVariateGen genServ = new WeibullGen(streamServ, alpha, lambda, delta);
    Resource server = new Resource(1, "The server");
    Tally meanInRep = new Tally("Average for current run");
    Tally statDiff = new Tally("Diff. on mean response times");
    class Terminal extends SimProcess {
        public void actions() {
            double arrivTime; // Arrival time of current request.
            double timeNeeded; // Server's time still needed for it.
            while (NumberOfTasks < N) {
                delay(genThink.nextDouble());
                arrivTime = Sim.time();
                timeNeeded = genServ.nextDouble();
                while (timeNeeded > q) {
                    server.request(1);
                    delay(q + overhead);
                    timeNeeded -= q;
                    server.release(1);
                }
                server.request(1); // Here, timeNeeded <= q.
                delay(timeNeeded + overhead);
                server.release(1);
                NumberOfTasks++;
                if (NumberOfTasks > N0) meanInRep.add(Sim.time() - arrivTime);
                // Take the observation if warmup is over.
            }
            Sim.stop(); // N tasks have now completed.
        }
    }
    private void simulOneRun() {
        SimProcess.init();
        server.init();
        meanInRep.init();
        NumberOfTasks = 0;
        for (int i = 1; i <= NumberOfTermainals; i++)
        new Terminal().schedule(0.0);
        Sim.start();
    }
    // Simulate numRuns pairs of runs and prints a confidence interval
    // on the difference of perf. for q sizes q1 and q2.
    public void simulateConfigs(double numRuns, double q1, double q2) {
        double mean1; // To memorize average for first configuration.
        for (int rep = 0; rep < numRuns; rep++) {
            q = q1;
            simulOneRun();
            mean1 = meanInRep.average();
            streamThink.resetStartSubstream();
            streamServ.resetStartSubstream();
            q = q2;
            simulOneRun();
            statDiff.add(mean1 - meanInRep.average());
            streamThink.resetNextSubstream();
            streamServ.resetNextSubstream();
        }
        statDiff.setConfidenceIntervalStudent();
        System.out.println(statDiff.report(0.9, 3));
    }
    public static void main(String[] args) {
        new RoundRobinQueue().simulateConfigs(10, 0.1, 0.2);
    }
}

Upvotes: 0

Views: 563

Answers (2)

Abhiram mishra
Abhiram mishra

Reputation: 1617

You are missing couple of jar files in your classpath. From the documentation it looks like you would need the following jars. http://www-labs.iro.umontreal.ca/~simardr/ssj/examples/examples.pdf

colt.jar,Blas.jar,optimization.jar ( this one in particular for your problem),jfreechart-.jar and jcommon-.jar

Upvotes: 1

Ahmad Tarraf
Ahmad Tarraf

Reputation: 89

i fixed the problem , the program needed an optimization library here to work , i added the jar file and it worked fine

Upvotes: 0

Related Questions