package org.joone.samples.engine.validation;

import java.util.*;

import org.joone.engine.*;
import org.joone.inspection.implementations.*;
import org.joone.io.*;
import org.joone.net.*;

/*
 * 

Title: Effort Estimations Through Neural Networks - Joone Test

*

Description: Stage II - Joone Pilot

*

Copyright: Copyright (c) 2003

*

Company: Motorola

* @author Sebastian Donatti - AGD013 * @version 1.0.0 */ public class NeuralNetTester implements Runnable,NeuralNetListener,NeuralValidationListener{ // Joone Global Variables private Vector listeners; private NeuralNet oldNetwork; private NeuralNet newNetwork; private Thread myThread=null; private double lastRSME; private int minimaEpochs; // JoonePilot Global Variables; private int problem; private boolean relaunch; private static int relaunchNumber; private boolean learnCurve; // Added to avoid to print all the intermediate errors when in learning curve mode // Launches the train & validation of one neural network - Class Constructor public NeuralNetTester(NeuralNet _network,boolean lCurve,int _problem){ problem=_problem; listeners=new Vector(); oldNetwork=_network; newNetwork=cloneNet(_network); learnCurve=lCurve; lastRSME=0; minimaEpochs=0; relaunch=false; } public void addValidationListener(NeuralValidationListener newListener){ if(!listeners.contains(newListener)){ listeners.addElement(newListener); } } // Trains the neural network - Class Method protected void train(){ newNetwork.getMonitor().addNeuralNetListener(this); newNetwork.getMonitor().setLearning(true); newNetwork.getMonitor().setValidation(false); newNetwork.start(); newNetwork.getMonitor().Go(); } // Validates the trained neural network - Class Method protected void validate(){ if(!learnCurve){ // Update Screen System.out.print("\nTraining Finished \n"); System.out.print("\nValidation Started\n\n"); } // Set all the parameters for the validation NeuralNetValidator nnv=new NeuralNetValidator(cloneNet(newNetwork)); nnv.addValidationListener(this); // Validate the network nnv.start(); } // Clones the neural network passed as parameter - Class Method private NeuralNet cloneNet(NeuralNet oldNet){ // Create a copy of the neural network oldNet.getMonitor().setExporting(true); NeuralNet newNet=oldNet.cloneNet(); oldNet.getMonitor().setExporting(false); // Clean the old listeners (This is a fundamental action to avoid that the validated net calls any method of previously registered listeners) newNet.removeAllListeners(); return newNet; } // Notifies all the registered listeners - Class Method private void fireNetValidated(NeuralValidationEvent event){ NeuralNet NN=(NeuralNet)event.getSource(); for(int i=0;i

Ads help maintain this website.