Exemple #1
0
        /// <summary>
        /// Gets the settings for an individual modeler prepared.  This function is
        /// intended to be called asynchronously.
        /// </summary>
        /// <param name="iServer"></param>
        /// <param name="iModeler"></param>
        /// <param name="Training"></param>
        /// <returns></returns>
        private bool InitializeModeler(IGPServer iServer, IGPModeler iModeler, GPModelingData Training)
        {
            //
            // The data we want to send is data appropriate for modeling.  Time Series
            // data needs to be transformed for the modeler.
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Loading training data...");
            }
            iModeler.Training = Training.TrainingForModeling(
                m_Profile.ModelType.InputDimension,
                m_Profile.ModelType.PredictionDistance);

            //
            // Prepare the function set for each server
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Transmitting user defined functions...");
            }
            IGPFunctionSet iFunctionSet = iServer.FunctionSet;
            //
            // Use a client side sponsor for this function set
            // TODO: This sponsor should really come from the server we obtained
            // the function set interface from.  The reason it currently isn't, is
            // because the whole "lease lifetime" thing isn't fully thought out yet
            // in this application.
            ILease LeaseInfo = (ILease)((MarshalByRefObject)iFunctionSet).GetLifetimeService();

            LeaseInfo.Register(m_FunctionSetSponsor);

            //
            // Let's go ahead and assign the same lease sponsor to the modeler
            LeaseInfo = (ILease)((MarshalByRefObject)iModeler).GetLifetimeService();
            LeaseInfo.Register(m_ModelerSponsor);

#if GPLOG
            GPLog.ReportLine("Loading UDFs...", true);
#endif

            foreach (string FunctionName in m_Profile.FunctionSet)
            {
#if GPLOG
                GPLog.ReportLine("   UDF: " + FunctionName, false);
#endif
                //
                // Load the Function from the database
                short  FunctionArity      = 0;
                bool   TerminalParameters = false;
                String FunctionCode       = "";
                if (GPDatabaseUtils.LoadFunctionFromDB(FunctionName, ref FunctionArity, ref TerminalParameters, ref FunctionCode, GPEnums.LANGUAGEID_CSHARP))
                {
                    //
                    // Add it to the function set
                    iFunctionSet.AddFunction(FunctionName, FunctionArity, TerminalParameters, FunctionCode);
                }
            }
            iFunctionSet.UseMemory = m_Profile.ModelingProfile.UseMemory;

            //
            // Assign it to the modeler
            iModeler.FunctionSet = iFunctionSet;

#if GPLOG
            GPLog.Report("Transmitting fitness function...", true);
#endif

            //
            // Pass the fitness function to each modeler
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Transmitting fitness function...");
            }
            String FitnessFunction = GPDatabaseUtils.FieldValue(m_Profile.FitnessFunctionID, "tblFitnessFunction", "Code");
            iModeler.FitnessFunction = FitnessFunction;

#if GPLOG
            GPLog.ReportLine("...Complete", false);
#endif

            //
            // Transmit the profile/modeling settings
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Transmitting modeling parameters...");
            }
            iModeler.Profile = m_Profile.ModelingProfile;
            //
            // Send over which ADF and ADLs to evolve
            foreach (byte adf in m_Profile.m_ADFSet)
            {
                iModeler.AddADF(adf);
            }
            foreach (byte adl in m_Profile.m_ADLSet)
            {
                iModeler.AddADL(adl);
            }
            foreach (byte adr in m_Profile.m_ADRSet)
            {
                iModeler.AddADR(adr);
            }

            return(true);
        }
 /// <summary>
 /// Add a new distributed node to this server
 /// </summary>
 /// <param name="iServer"></param>
 public void AddModeler(IGPModeler iServer)
 {
     m_Servers.Add(iServer);
 }