Пример #1
0
        public override void Execute(Context c)
        {
            if ((m_parameters.Parameters == null || m_parameters.Parameters.Count == 0) && m_paramFunction == null)
            {
                m_worldModel.RunProcedure(m_procedure);
            }
            else
            {
                Parameters paramValues = new Parameters();
                Element proc = m_worldModel.Procedure(m_procedure);

                // TO DO: Check number of parameters matches, and that the function exists

                int cnt = 0;
                foreach (IFunction<object> f in m_parameters.Parameters)
                {
                    paramValues.Add((string)proc.Fields[FieldDefinitions.ParamNames][cnt], f.Execute(c));
                    cnt++;
                }

                if (m_paramFunction != null)
                {
                    paramValues.Add((string)proc.Fields[FieldDefinitions.ParamNames][cnt], m_paramFunction);
                }

                m_worldModel.RunProcedure(m_procedure, paramValues, false);
            }
        }
Пример #2
0
 //判断是否有MV
 public bool CanFollowMV(string keyword)
 {
     Parameters parameters = new Parameters();
     parameters.Add("searchType", "mv");
     parameters.Add("keyword", keyword);
     string url = ConnectionBase.ConstructUrlWithParameters("http://www.yinyuetai.com/search/mv", parameters);
     string searchresult = new ConnectionBase().Get(url);
     if (string.IsNullOrEmpty(searchresult))
         return false;
     else
     {
         MatchCollection mc = Regex.Matches(searchresult, @"<div class=""noResult"">");
         if (mc.Count != 0)
         {
             return false;
         }
         else
         {
             MatchCollection mc1 = Regex.Matches(searchresult, @"<div class=""title mv_title"".*?</div>", RegexOptions.Singleline);
             if (mc1.Count == 0)
                 return false;
             else
             {
                 Match tmpmatch = Regex.Match(mc1[0].Groups[0].Value, @"href=""([^\""]+?)""");
                 mvUrl = @"http://www.yinyuetai.com/video/player/" + tmpmatch.Groups[1].Value.Substring(7) + @"/v_0.swf";
                 return true;
             }
         }
     }
 }
        public bool AddNewUser(Core.User user)
        {
            try
            {
                Parameters parameters = new Parameters();
                parameters.Add("@FirstName", user.FirstName);
                parameters.Add("@UserName", user.UserName);
                parameters.Add("@Pass", user.Password);
                parameters.Add("@RoleId", user.RoleId);
                parameters.Add("@IsActive", user.IsActiveUser);

                if (string.IsNullOrWhiteSpace(user.LastName))
                    parameters.Add("@LastName", DBNull.Value);
                else
                    parameters.Add("@LastName", user.LastName);

                if (string.IsNullOrWhiteSpace(user.NICNumber))
                    parameters.Add("@NICNumber", DBNull.Value);
                else
                    parameters.Add("@NICNumber", user.NICNumber);

                ExecuteNoneQuery("proc_AddNewUser", parameters);
                return true;
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool AddNewPumpstation(PumpStation pumpstation)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@PumpstationName", pumpstation.PumpStationName);
         parameters.Add("@Description", pumpstation.Description);
         ExecuteNoneQuery("proc_AddNewPumpstation", parameters);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
 public DataSet GetFuelAndLubricantReport(DateTime startDate, DateTime endDate, int pumpstationId)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@StartDate", startDate);
         parameters.Add("@EndDate", endDate);
         parameters.Add("@PumpstationId", pumpstationId);
         return ExecuteDataSet("proc_RptFuelLubricantReport", parameters);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public DataSet GetFuelConsumptionReport(DateTime startDate, DateTime endDate)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@StartDate", startDate);
         parameters.Add("@EndDate", endDate);
         return ExecuteDataSet("proc_RptFuelConsumptionReport", parameters);
         //return ExecuteDataSet("proc_FuelConsumptionReport", parameters);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool IsValidPasswordRestRequest(int userId, string oldPassword)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@UserId", userId);
         parameters.Add("@OldPassword", oldPassword);
         int value = ExecuteScalar("proc_ValidPasswordResetRequest", parameters);
         return value == 1;
     }
     catch (Exception)
     {
         throw;
     }
 }
 public DataSet GetDriverTimeSheetReport(string driverName, DateTime startDate, DateTime endDate)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@DriverOperatorName", driverName);
         parameters.Add("@StartDate", startDate);
         parameters.Add("@EndDate", endDate);
         return ExecuteDataSet("proc_RptDriverOperatorTimeSheet", parameters);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool AddNewFuelType(CECRunningChart.Core.FuelType fuelType)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@FuelName", fuelType.FuelName);
         parameters.Add("@Rate", fuelType.FuelRate);
         ExecuteNoneQuery("proc_AddNewFuelType", parameters);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
 public bool AddNewLubricantType(CECRunningChart.Core.LubricantType lubricantType)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@LubricantType", lubricantType.LubricantName);
         parameters.Add("@Rate", lubricantType.LubricantRate);
         ExecuteNoneQuery("proc_AddNewLubricantType", parameters);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
 public bool UpdatePumpstation(PumpStation pumpstation)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@PumpstationId", pumpstation.Id);
         parameters.Add("@PumpstationName", pumpstation.PumpStationName);
         parameters.Add("@Description", pumpstation.Description);
         ExecuteNoneQuery("proc_UpdatePumpstation", parameters);
         return true;
     }
     catch (Exception)
     {
         throw;
     }
 }
        public void ApproveRunningChart(int runningChartId, int approvedBy, DateTime approvedDate)
        {
            try
            {
                Parameters parameters = new Parameters();
                parameters.Add("@RunningchartId", runningChartId);
                parameters.Add("@ApprovedBy", approvedBy);
                parameters.Add("@ApprovedDate", approvedDate);

                ExecuteNoneQuery("proc_ApproveRunningChart", parameters);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #13
0
        public override void Execute(Context c)
        {
            if (m_parameters == null)
            {
                throw new NotImplementedException();
            }
            else
            {
                Element obj = m_appliesTo.Execute(c);
                string delName = m_delegate.Execute(c);
                DelegateImplementation impl = obj.Fields.Get(delName) as DelegateImplementation;

                if (impl == null)
                {
                    throw new Exception(string.Format("Object '{0}' has no delegate implementation '{1}'", obj.Name, m_delegate));
                }

                Parameters paramValues = new Parameters();

                int cnt = 0;
                foreach (IFunction<object> f in m_parameters.Parameters)
                {
                    paramValues.Add((string)impl.Definition.Fields[FieldDefinitions.ParamNames][cnt], f.Execute(c));
                    cnt++;
                }

                m_worldModel.RunScript(impl.Implementation.Fields[FieldDefinitions.Script], paramValues, obj);
            }
        }
 public Parameters ToParameters() {
     var parameters = new Parameters(new DefaultFactory(new TestLogger()));
     foreach (var p in _params) {
         parameters.Add(p.Key, p.Value);
     }
     return parameters;
 }
Пример #15
0
        public Parameters Calculate(Parameters inputparams)
        {
            double fi = (double)inputparams["ko_razr"].Value;
            double VcMax = (double)inputparams["sko_str_max"].Value;
            double psi = (double)inputparams["ko_zap"].Value;
            double Qy = (double)inputparams["teor_pr_uct1"].Value;
            double F = (double)inputparams["s_sech_konv"].Value;
            double H = (double)inputparams["mo_ugpl_1"].Value;
            double A = (double)inputparams["so_ugre"].Value;
            double A2 = (double)inputparams["A2_pol"].Value;
            double A1 = (double)inputparams["A1_pol"].Value;
            double A0 = (double)inputparams["A0_pol"].Value;
            double VkMax = (double)inputparams["sko_konv_max"].Value;
            double y = (double)inputparams["pl_ug"].Value;

            double fi1 = 1.6;
            double Vc = VcMax / 60;
            double Vk = VkMax / 60;
            double yn = y / fi;
            double Qkr = 60 * F * psi * Vk * yn;
            double Kr = Qy / Qkr;
            double Ko = (Qy * VkMax) / (Qkmax * psi * Vc);
            double C = 1 / (4 * Ko - 1);
            if (C < 1)
            {
                C = 1;
            }

            double h1 = A2 * C * C + A1 * C + A0;
            double Hstrug = (h1 * 10 * F * fi1) / (H * fi);
            double Vk = Vc / C;

            Parameters result = new Parameters();

            result.Add("max_depth_reg", Hstrug);

            result.Add("c_sg_konv", C);

            result.Add("proiz_konv", Qkr);

            result.Add("v_konv", Vk);

            result.Add("ko_skor", Ko);

            return result;
        }
 public bool AddNewProject(Core.Project project)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@Name", project.ProjectName);
         parameters.Add("@Manager", project.ProjectManager);
         parameters.Add("@Location", project.ProjectLocation);
         parameters.Add("@Description", project.ProjectDescription);
         parameters.Add("@IsActive", project.IsActiveProject);
         ExecuteNoneQuery("proc_AddNewProject", parameters);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Пример #17
0
        private bool GetNewList(string type)
        {
            bool retSuccess = true;
            Song currentSong = currentQueue[currentSongIdx];
            string sidstr = (currentSongIdx == 0) ? string.Empty : currentSong.sid;
            Random random = new Random();
		    byte[] bytes = new byte[8];
            random.NextBytes(bytes);
            string r = (BitConverter.ToUInt64(bytes, 0) % 0xFFFFFFFFFF).ToString("x10");
            Parameters parameters = new Parameters();
            parameters.Add("type", type);
            parameters.Add("pb", "64");
            parameters.Add("sid", sidstr);
            parameters.Add("pt", currentSongPT.ToString());
            parameters.Add("channel", channelNo.ToString());
            parameters.Add("from", "mainsite");
            parameters.Add("r", r);
            string PostUrl = ConnectionBase.ConstructUrlWithParameters(@"http://douban.fm/j/mine/playlist", parameters);
            string SongJson = new ConnectionBase().Get(PostUrl);
            SongResult songresult = SongResult.FromJson(SongJson);
            if (type == "e")
                retSuccess = true;
            else if (songresult == null)
                retSuccess = false;
            else if (songresult != null && songresult.r != 0)
                retSuccess = false;
            else
            {
                if (songresult != null)
                {
                    if (songresult.song.Count == 0)
                        retSuccess = false;
                    else
                    {
                        if (type != "p")
                        {
                            currentQueue.Clear();
                            currentSongIdx = 0;
                        }
                        else
                        {
                            Song lastSong = currentQueue[currentQueue.Count - 1];
                            currentQueue.Clear();
                            currentSongIdx = 0;
                            currentQueue.Add(lastSong);
                        }
                        if (type == "r" || type == "u")
                            currentQueue.Add(currentSong);
                        
                        foreach (Song s in songresult.song)
                        {
                            if (s.subtype != "T")//剔除广告音频
                                currentQueue.Add(s);
                        }
                    }
                }
            }
            return retSuccess;
        }
            //http://api.bitcoincharts.com/v1/trades.csv?symbol=mtgoxUSD
            public HttpRequestMessage Build() {
                var parameters = new Parameters();
                parameters.Add("symbol", "{0}{1}".FormatWith(_settings.Market, _settings.Currency));

                if(_settings.Start != default(DateTimeOffset)) {
                    parameters.Add("start", _settings.Start.ToUnixTime());
                }

                var query = parameters.ToQueryString();

                var uri = "v1/trades.csv?{0}".FormatWith(query);

                var request = new HttpRequestMessage {
                    Method = HttpMethod.Get,
                    RequestUri = new Uri(uri, UriKind.Relative)
                };

                return request;
            }
        public int AddRunningchart(Core.Runningchart runningChart)
        {
            int runningchartId = 0;
            try
            {
                // 1. Add details to dbo.Runningchart table
                Parameters chartParameters = new Parameters();
                AddRunningChartParameters(runningChart, chartParameters);
                var output = ExecuteNoneQueryWithOutputParams("proc_AddRunningChart", chartParameters);
                runningchartId = Convert.ToInt32(output["@RunningchartId"]);

                // 2. Add details to dbo.RunningchartDetails table
                Parameters chartDetailsParameters;
                foreach (var detail in runningChart.RunningchartDetails)
                {
                    detail.RunningchartId = runningchartId;
                    chartDetailsParameters = new Parameters();
                    AddRunningchartDetailsParameters(detail, chartDetailsParameters);
                    ExecuteNoneQuery("proc_AddRunningchartDetails", chartDetailsParameters);
                }

                // 3. Add details to dbo.RunningchartPumpstation table
                Parameters chartPumpstationParameters;
                foreach (var pumpstation in runningChart.RunningchartPumpstation)
                {
                    pumpstation.RunningchartId = runningchartId;
                    chartPumpstationParameters = new Parameters();
                    AddRunningchartPumpstationParams(pumpstation, chartPumpstationParameters);
                    ExecuteNoneQuery("proc_AddRunningchartPumpstation", chartPumpstationParameters);
                }

                // 4. Add details to dbo.RunningchartLubricants table
                Parameters chartLubricantParameters;
                foreach (var lubricant in runningChart.RunningchartLubricants)
                {
                    lubricant.RunningchartId = runningchartId;
                    chartLubricantParameters = new Parameters();
                    AddRunningchartLubricantParams(lubricant, chartLubricantParameters);
                    ExecuteNoneQuery("proc_AddRunningchartLubricant", chartLubricantParameters);
                }

                return runningchartId;
            }
            catch (Exception)
            {
                if (runningchartId > 0)
                {
                    Parameters cleanupParameters = new Parameters();
                    cleanupParameters.Add("@RunningchartId", runningchartId);
                    ExecuteNoneQuery("proc_CleanupRunningchartRecords", cleanupParameters);
                }
                throw;
            }
        }
        public DataSet GetHireBillPrivateReport(DateTime startDate, DateTime endDate, int vehicleId, 
            out DataSet pumpStationDataSet, out DataSet lubricantsDataSet)
        {
            try
            {
                Parameters parameters = new Parameters();
                parameters.Add("@StartDate", startDate);
                parameters.Add("@EndDate", endDate);
                parameters.Add("@VehicleId", vehicleId);

                var detailsDataSet = ExecuteDataSet("dbo.proc_RptHireBillPrivateReport", parameters);
                pumpStationDataSet = ExecuteDataSet("dbo.proc_RptHireBillPrivateReportPumpstations", parameters);
                lubricantsDataSet = ExecuteDataSet("dbo.proc_RptHireBillPrivateReportLubricants", parameters);
                return detailsDataSet;
            }
            catch (Exception)
            {
                throw;
            }
        }
 public DataSet GetPumpstation(int id)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@PumpstationId", id);
         return ExecuteDataSet("proc_GetPumpstationById", parameters);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public DataSet GetUser(int id)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@UserId", id);
         return ExecuteDataSet("proc_GetUserById", parameters);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool DeleteProject(int id)
 {
     try
     {
         Parameters parameters = new Parameters();
         parameters.Add("@ProjectId", id);
         ExecuteNoneQuery("proc_DeleteProject", parameters);
         return true;
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #24
0
        public SULibrary.Parameters LoadParams(IList<MetadataField> paramsNames)
        {
            Parameters result = new Parameters();

            foreach (MetadataField param in paramsNames)
            {
                double? value = SelectFieldValue(param);
                if (value.HasValue)
                {
                    result.Add(param.Name, value.Value);
                }
            }

            return result;
        }
Пример #25
0
        public Parameters Calculate(Parameters inputparams)
        {
            // schityvanie parametrov v peremennye

            double Hmax = (double)inputparams["max_mopl"].Value;
            double Hmin = (double)inputparams["min_mopl"].Value;
            double HStrugMax = (double)inputparams["max_depth_rez"].Value;
            double B = (double)inputparams["excess_rez_nad_str"].Value;
            double Hpogr = (double)inputparams["height_pogruz"].Value;
            double Kc = (double)inputparams["koef_h_str"].Value;

            // vychisleniya

            double HcMin = Hpogr + 4.8 * Hmin * HStrugMax + B;
            double HcMax = Kc * Hmax;

            //sapis' parametrov v basu

            Parameters result = new Parameters();
            result.Add("h_smax", HcMax);
            result.Add("h_smin", HcMin);

            return result;
        }
Пример #26
0
        /// <summary>
        /// Execute an SQL Command (SELECT) using the _IDBClass properties in the query, only when properties are not null
        /// SQLSelect can be used to return only what was specified, ex. SQLSelect = "name, phone"
        /// SQLWhere can be used to restrict, ex. SQLWhere = "age > 23"
        /// SQLOrderBy can be used to sort the result, ex. SQLOrderBy = "date_birth desc, name asc"
        /// </summary>
        /// <param name="_IDBClass"></param>
        /// <returns>The Select Results (BPA.Data.Hashtables)</returns>
        public static Hashtables Select(IDBClass _IDBClass)
        {
            if (_IDBClass.SQLSelect.IsNullOrEmpty())
                _IDBClass.SQLSelect = "*";

            StringBuilder SQLQuery = new StringBuilder(String.Format(" SELECT {0} FROM {1} ", _IDBClass.SQLSelect, GETDBName(_IDBClass)));

            var props = (from t in _IDBClass.GetType().GetProperties()
                         where t.GetValue(_IDBClass, null) != null
                         && t.Name != "PrimaryKey"
                         && t.Name != "SQLSelect"
                         && t.Name != "SQLWhere"
                         && t.Name != "SQLOrderBy"
                         select new
                         {
                             Name = t.Name,
                             Value = t.GetValue(_IDBClass, null),
                             DbType = GETDBType((t.GetValue(_IDBClass, null)).GetType().Name)
                         });

            if (props.Count() != 0)
                SQLQuery.Append(" WHERE ");

            Parameters p = new Parameters();

            foreach (var prop in props)
            {
                p.Add(new Parameter(String.Format("#{0}", prop.Name), prop.Value, prop.DbType));
                SQLQuery.Append(String.Format(" AND {0} = #{1} ", prop.Name, prop.Name));
            }

            if (p.Count != 0)
                SQLQuery = SQLQuery.Replace(" WHERE  AND ", " WHERE ");

            if (!_IDBClass.SQLWhere.IsNull())
            {
                if (!SQLQuery.ToString().Contains("WHERE"))
                    SQLQuery.Append(String.Format(" WHERE {0} ", _IDBClass.SQLWhere));
                else
                    SQLQuery.Append(String.Format(" AND {0} ", _IDBClass.SQLWhere));
            }

            if (!_IDBClass.SQLOrderBy.IsNullOrEmpty())
                SQLQuery.Append(String.Format(" ORDER BY {0} ", _IDBClass.SQLOrderBy));

            return DBExecuteReader(SQLQuery.ToString(), p);
        }
Пример #27
0
        public string GetDynamicText(string t, params Element[] obj)
        {
            Parameters parameters;

            if (obj.Length == 1)
            {
                parameters = new Parameters("object", obj[0]);
            }
            else
            {
                parameters = new Parameters();
                for (int i = 0; i < obj.Length; i++)
                {
                    parameters.Add("object" + (i + 1).ToString(), obj[i]);
                }
            }

            return GetDynamicTextInternal(t, parameters);
        }
Пример #28
0
        public SULibrary.Parameters LoadParams(string[] paramsNames)
        {
            Parameters result = new Parameters();

            foreach (string paramname in paramsNames)
            {
                //  получаем информацию о поле
                MetadataField fieldInfo = _manager.GetFieldInfo(paramname);
                if (fieldInfo == null) throw new ArgumentException("Параметр с именем '" + paramname + "'");

                double? value = SelectFieldValue(fieldInfo);
                if (value.HasValue)
                {
                    result.Add(fieldInfo.Name, value.Value);
                }
            }

            return result;
        }
Пример #29
0
        void Variables_InvokeFunction(object sender, InvokeFunctionEventArgs e)
        {
            if (e.FunctionName == "IsDefined")
            {
                e.Result = m_context.Parameters.ContainsKey((string)e.Arguments[0]);
                return;
            }
            Element proc = m_worldModel.Procedure(e.FunctionName);
            Parameters parameters = new Parameters();
            int cnt = 0;
            // TO DO: Check number of parameters matches
            foreach (object val in e.Arguments)
            {
                parameters.Add((string)proc.Fields[FieldDefinitions.ParamNames][cnt], val);
                cnt++;
            }

            e.Result = m_worldModel.RunProcedure(e.FunctionName, parameters, true);
        }
Пример #30
0
        /// <summary>
        /// Достаем параметры из установки
        /// </summary>
        /// <param name="names">название параметров</param>
        /// <param name="plowmachine">струговя установка</param>
        /// <returns></returns>
        public static Parameters GetParams(string[] names, PlowMachine plowmachine)
        {
            Parameters result = new Parameters();

            foreach (var param in names)
            {
                foreach (var module in plowmachine.Modules.Values)
                {
                    //
                    //  выбираме параметры, названия которых совпадают
                    //
                    var moduleparam = from mp in module.ModuleParams
                                      where mp.Name.Equals(param, StringComparison.InvariantCultureIgnoreCase)
                                      select mp;
                    if (moduleparam.Count() != 0)
                        result.Add(moduleparam.First());
                }
            }

            return result;
        }
Пример #31
0
        public DisqusUserListFollowingForumsRequest User(string username)
        {
            Parameters.Add(new KeyValuePair <string, string>("user:username", username));

            return(this);
        }
Пример #32
0
        private void AfterDeserialization()
        {
            #region conversion of old NSM parameters
            if (Parameters.ContainsKey(SelectorParameterName)) // change SelectorParameter type from ISelector to ISingleObjectiveSelector
            {
                ValueParameter <ISelector> param = Parameters[SelectorParameterName] as ValueParameter <ISelector>;
                if (param != null)
                {
                    ISingleObjectiveSelector selector = param.Value as ISingleObjectiveSelector;
                    if (selector == null)
                    {
                        selector = new TournamentSelector();
                    }
                    Parameters.Remove(SelectorParameterName);
                    Parameters.Add(new ValueParameter <ISingleObjectiveSelector>(SelectorParameterName, "The inner selection operator to select the parents.", selector));
                }
            }
            // FixedValueParameter for quality difference percentage, max attempts, use range
            if (Parameters.ContainsKey(QualityDifferencePercentageParameterName))
            {
                ValueParameter <PercentValue> param = Parameters[QualityDifferencePercentageParameterName] as ValueParameter <PercentValue>;
                if (!(param is FixedValueParameter <PercentValue>))
                {
                    PercentValue diff = param != null ? param.Value as PercentValue : null;
                    if (diff == null)
                    {
                        diff = new PercentValue(0.05);
                    }
                    Parameters.Remove(QualityDifferencePercentageParameterName);
                    Parameters.Add(new FixedValueParameter <PercentValue>(QualityDifferencePercentageParameterName, "The minimum quality difference from parent1 to parent2 to accept the selection.", diff));
                }
            }
            if (Parameters.ContainsKey(QualityDifferenceMaxAttemptsParameterName))
            {
                ValueParameter <IntValue> param = Parameters[QualityDifferenceMaxAttemptsParameterName] as ValueParameter <IntValue>;
                if (!(param is FixedValueParameter <IntValue>))
                {
                    IntValue attempts = param != null ? param.Value as IntValue : null;
                    if (attempts == null)
                    {
                        attempts = new IntValue(5);
                    }
                    Parameters.Remove(QualityDifferenceMaxAttemptsParameterName);
                    Parameters.Add(new FixedValueParameter <IntValue>(QualityDifferenceMaxAttemptsParameterName, "The maximum number of attempts to find parents which differ in quality.", attempts));
                }
            }
            if (Parameters.ContainsKey(QualityDifferenceUseRangeParameterName))
            {
                ValueParameter <BoolValue> param = Parameters[QualityDifferenceUseRangeParameterName] as ValueParameter <BoolValue>;
                if (!(param is FixedValueParameter <BoolValue>))
                {
                    BoolValue range = param != null ? param.Value as BoolValue : null;
                    if (range == null)
                    {
                        range = new BoolValue(true);
                    }
                    Parameters.Remove(QualityDifferenceUseRangeParameterName);
                    Parameters.Add(new FixedValueParameter <BoolValue>(QualityDifferenceUseRangeParameterName, "Use the range from minimum to maximum quality as basis for QualityDifferencePercentage.", range));
                }
            }
            if (!Parameters.ContainsKey(QualityDifferenceUseRangeParameterName)) // add use range parameter
            {
                Parameters.Add(new FixedValueParameter <BoolValue>(QualityDifferenceUseRangeParameterName, "Use the range from minimum to maximum quality as basis for QualityDifferencePercentage.", new BoolValue(true)));
            }
            #endregion

            RegisterParameterEventHandlers();
        }
        /// <summary>
        /// Initializes a new instance of <see cref="BreederGeneticAlgorithmManipulator"/> with two
        /// parameters (<c>Bounds</c> and <c>SearchIntervalFactor</c>).
        /// </summary>
        public BreederGeneticAlgorithmManipulator()
            : base()
        {
            Parameters.Add(new ValueLookupParameter <DoubleValue>("SearchIntervalFactor", @"Scales the manipulation strength as a factor of the range. The range is determined by the bounds interval.
A value of 0.1 means that certain components of the vector are moved by values in the non-uniform interval [0;0.1*range].", new DoubleValue(0.1)));
        }
Пример #34
0
 public void AddWithValue(string paramname, object o)
 {
     Parameters.Add(new MySqlParameter(paramname, o));
 }
        public EvolutionStrategy()
            : base()
        {
            Parameters.Add(new ValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
            Parameters.Add(new ValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
            Parameters.Add(new ValueParameter <IntValue>("PopulationSize", "µ (mu) - the size of the population.", new IntValue(20)));
            Parameters.Add(new ValueParameter <IntValue>("ParentsPerChild", "ρ (rho) - how many parents should be recombined.", new IntValue(1)));
            Parameters.Add(new ValueParameter <IntValue>("Children", "λ (lambda) - the size of the offspring population.", new IntValue(100)));
            Parameters.Add(new ValueParameter <IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
            Parameters.Add(new ValueParameter <BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population).", new BoolValue(true)));
            Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false))
            {
                Hidden = true
            });
            Parameters.Add(new OptionalConstrainedValueParameter <ICrossover>("Recombinator", "The operator used to cross solutions."));
            Parameters.Add(new ConstrainedValueParameter <IManipulator>("Mutator", "The operator used to mutate solutions."));
            Parameters.Add(new OptionalConstrainedValueParameter <IStrategyParameterCreator>("StrategyParameterCreator", "The operator that creates the strategy parameters."));
            Parameters.Add(new OptionalConstrainedValueParameter <IStrategyParameterCrossover>("StrategyParameterCrossover", "The operator that recombines the strategy parameters."));
            Parameters.Add(new OptionalConstrainedValueParameter <IStrategyParameterManipulator>("StrategyParameterManipulator", "The operator that manipulates the strategy parameters."));
            Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));

            RandomCreator             randomCreator           = new RandomCreator();
            SolutionsCreator          solutionsCreator        = new SolutionsCreator();
            SubScopesCounter          subScopesCounter        = new SubScopesCounter();
            UniformSubScopesProcessor strategyVectorProcessor = new UniformSubScopesProcessor();
            Placeholder               strategyVectorCreator   = new Placeholder();
            ResultsCollector          resultsCollector        = new ResultsCollector();
            EvolutionStrategyMainLoop mainLoop = new EvolutionStrategyMainLoop();

            OperatorGraph.InitialOperator = randomCreator;

            randomCreator.RandomParameter.ActualName          = "Random";
            randomCreator.SeedParameter.ActualName            = SeedParameter.Name;
            randomCreator.SeedParameter.Value                 = null;
            randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
            randomCreator.SetSeedRandomlyParameter.Value      = null;
            randomCreator.Successor = solutionsCreator;

            solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
            solutionsCreator.Successor = subScopesCounter;

            subScopesCounter.Name = "Initialize EvaluatedSolutions";
            subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
            subScopesCounter.Successor = strategyVectorProcessor;

            strategyVectorProcessor.Operator  = strategyVectorCreator;
            strategyVectorProcessor.Successor = resultsCollector;

            strategyVectorCreator.OperatorParameter.ActualName = "StrategyParameterCreator";

            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
            resultsCollector.ResultsParameter.ActualName = "Results";
            resultsCollector.Successor = mainLoop;

            mainLoop.RandomParameter.ActualName             = RandomCreator.RandomParameter.ActualName;
            mainLoop.PopulationSizeParameter.ActualName     = PopulationSizeParameter.Name;
            mainLoop.ParentsPerChildParameter.ActualName    = ParentsPerChildParameter.Name;
            mainLoop.ChildrenParameter.ActualName           = ChildrenParameter.Name;
            mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
            mainLoop.PlusSelectionParameter.ActualName      = PlusSelectionParameter.Name;
            mainLoop.ReevaluateElitesParameter.ActualName   = ReevaluateElitesParameter.Name;
            mainLoop.MutatorParameter.ActualName            = MutatorParameter.Name;
            mainLoop.RecombinatorParameter.ActualName       = RecombinatorParameter.Name;
            mainLoop.AnalyzerParameter.ActualName           = AnalyzerParameter.Name;
            mainLoop.ResultsParameter.ActualName            = "Results";
            mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";

            qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
            ParameterizeAnalyzers();
            UpdateAnalyzers();

            Initialize();
        }
 public PotvinTwoOptStarMoveGenerator()
     : base()
 {
     Parameters.Add(new LookupParameter <PotvinTwoOptStarMove>("PotvinTwoOptStarMove", "The moves that should be generated in subscopes."));
     Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes."));
 }
Пример #37
0
        private void Initialize()
        {
            #region Create parameters
            Parameters.Add(new ValueLookupParameter <IRandom>("Random", "A pseudo random number generator."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
            Parameters.Add(new LookupParameter <DoubleValue>("Quality", "The value which represents the quality of a solution."));
            Parameters.Add(new LookupParameter <DoubleValue>("BestLocalQuality", "The value which represents the best quality found so far."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("BestKnownQuality", "The problem's best known quality value found so far."));
            Parameters.Add(new LookupParameter <DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
            Parameters.Add(new LookupParameter <IntValue>("Iterations", "The number of iterations performed."));
            Parameters.Add(new ValueLookupParameter <IntValue>("MaximumIterations", "The maximum number of generations which should be processed."));
            Parameters.Add(new ValueLookupParameter <VariableCollection>("Results", "The variable collection where results should be stored."));

            Parameters.Add(new ValueLookupParameter <IOperator>("MoveGenerator", "The operator that generates the moves."));
            Parameters.Add(new ValueLookupParameter <IOperator>("MoveMaker", "The operator that performs a move and updates the quality."));
            Parameters.Add(new ValueLookupParameter <IOperator>("MoveEvaluator", "The operator that evaluates a move."));

            Parameters.Add(new ValueLookupParameter <IOperator>("Analyzer", "The operator used to analyze the solution and moves."));
            Parameters.Add(new LookupParameter <IntValue>("EvaluatedMoves", "The number of evaluated moves."));
            #endregion

            #region Create operators
            SubScopesProcessor        subScopesProcessor0    = new SubScopesProcessor();
            Assigner                  bestQualityInitializer = new Assigner();
            Placeholder               analyzer1                   = new Placeholder();
            ResultsCollector          resultsCollector1           = new ResultsCollector();
            SubScopesProcessor        mainProcessor               = new SubScopesProcessor();
            Placeholder               moveGenerator               = new Placeholder();
            UniformSubScopesProcessor moveEvaluationProcessor     = new UniformSubScopesProcessor();
            Placeholder               moveEvaluator               = new Placeholder();
            SubScopesCounter          subScopesCounter            = new SubScopesCounter();
            BestSelector              bestSelector                = new BestSelector();
            SubScopesProcessor        moveMakingProcessor         = new SubScopesProcessor();
            UniformSubScopesProcessor selectedMoveMakingProcessor = new UniformSubScopesProcessor();
            QualityComparator         qualityComparator           = new QualityComparator();
            ConditionalBranch         improvesQualityBranch       = new ConditionalBranch();
            Placeholder               moveMaker                   = new Placeholder();
            Assigner                  bestQualityUpdater          = new Assigner();
            ResultsCollector          resultsCollector2           = new ResultsCollector();
            MergingReducer            mergingReducer              = new MergingReducer();
            Placeholder               analyzer2                   = new Placeholder();
            SubScopesRemover          subScopesRemover            = new SubScopesRemover();
            IntCounter                iterationsCounter           = new IntCounter();
            Comparator                iterationsComparator        = new Comparator();
            ConditionalBranch         iterationsTermination       = new ConditionalBranch();

            bestQualityInitializer.Name = "Initialize BestQuality";
            bestQualityInitializer.LeftSideParameter.ActualName  = BestLocalQualityParameter.Name;
            bestQualityInitializer.RightSideParameter.ActualName = QualityParameter.Name;

            analyzer1.Name = "Analyzer (placeholder)";
            analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;

            resultsCollector1.CopyValue = new BoolValue(false);
            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>(IterationsParameter.Name));
            resultsCollector1.CollectedValues.Add(new LookupParameter <DoubleValue>(BestLocalQualityParameter.Name, null, BestLocalQualityParameter.Name));
            resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;

            moveGenerator.Name = "MoveGenerator (placeholder)";
            moveGenerator.OperatorParameter.ActualName = MoveGeneratorParameter.Name;

            moveEvaluationProcessor.Parallel = new BoolValue(true);

            moveEvaluator.Name = "MoveEvaluator (placeholder)";
            moveEvaluator.OperatorParameter.ActualName = MoveEvaluatorParameter.Name;

            subScopesCounter.Name = "Increment EvaluatedMoves";
            subScopesCounter.ValueParameter.ActualName = EvaluatedMovesParameter.Name;

            bestSelector.CopySelected = new BoolValue(false);
            bestSelector.MaximizationParameter.ActualName         = MaximizationParameter.Name;
            bestSelector.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
            bestSelector.QualityParameter.ActualName = MoveQualityParameter.Name;

            qualityComparator.LeftSideParameter.ActualName  = MoveQualityParameter.Name;
            qualityComparator.RightSideParameter.ActualName = QualityParameter.Name;
            qualityComparator.ResultParameter.ActualName    = "IsBetter";

            improvesQualityBranch.ConditionParameter.ActualName = "IsBetter";

            moveMaker.Name = "MoveMaker (placeholder)";
            moveMaker.OperatorParameter.ActualName = MoveMakerParameter.Name;

            bestQualityUpdater.Name = "Update BestQuality";
            bestQualityUpdater.LeftSideParameter.ActualName  = BestLocalQualityParameter.Name;
            bestQualityUpdater.RightSideParameter.ActualName = QualityParameter.Name;

            resultsCollector2.CopyValue = new BoolValue(false);
            resultsCollector2.CollectedValues.Add(new LookupParameter <DoubleValue>(BestLocalQualityParameter.Name, null, BestLocalQualityParameter.Name));
            resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;

            analyzer2.Name = "Analyzer (placeholder)";
            analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;

            subScopesRemover.RemoveAllSubScopes = true;

            iterationsCounter.Name      = "Iterations Counter";
            iterationsCounter.Increment = new IntValue(1);
            iterationsCounter.ValueParameter.ActualName = IterationsParameter.Name;

            iterationsComparator.Name       = "Iterations >= MaximumIterations";
            iterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
            iterationsComparator.LeftSideParameter.ActualName  = IterationsParameter.Name;
            iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
            iterationsComparator.ResultParameter.ActualName    = "Terminate";

            iterationsTermination.Name = "Iterations Termination Condition";
            iterationsTermination.ConditionParameter.ActualName = "Terminate";
            #endregion

            #region Create operator graph
            OperatorGraph.InitialOperator = subScopesProcessor0; // don't change this without adapting the constructor of LocalSearchImprovementOperator
            subScopesProcessor0.Operators.Add(bestQualityInitializer);
            subScopesProcessor0.Successor    = resultsCollector1;
            bestQualityInitializer.Successor = analyzer1;
            analyzer1.Successor         = null;
            resultsCollector1.Successor = mainProcessor;
            mainProcessor.Operators.Add(moveGenerator);
            mainProcessor.Successor           = iterationsCounter;
            moveGenerator.Successor           = moveEvaluationProcessor;
            moveEvaluationProcessor.Operator  = moveEvaluator;
            moveEvaluationProcessor.Successor = subScopesCounter;
            moveEvaluator.Successor           = null;
            subScopesCounter.Successor        = bestSelector;
            bestSelector.Successor            = moveMakingProcessor;
            moveMakingProcessor.Operators.Add(new EmptyOperator());
            moveMakingProcessor.Operators.Add(selectedMoveMakingProcessor);
            moveMakingProcessor.Successor        = mergingReducer;
            selectedMoveMakingProcessor.Operator = qualityComparator;
            qualityComparator.Successor          = improvesQualityBranch;
            improvesQualityBranch.TrueBranch     = moveMaker;
            improvesQualityBranch.FalseBranch    = null;
            improvesQualityBranch.Successor      = null;
            moveMaker.Successor               = bestQualityUpdater;
            bestQualityUpdater.Successor      = null;
            mergingReducer.Successor          = analyzer2;
            analyzer2.Successor               = subScopesRemover;
            subScopesRemover.Successor        = null;
            iterationsCounter.Successor       = iterationsComparator;
            iterationsComparator.Successor    = iterationsTermination;
            iterationsTermination.TrueBranch  = null;
            iterationsTermination.FalseBranch = mainProcessor;
            #endregion
        }
Пример #38
0
 public FindNode(NodeId id, NodeId target)
     : base(id, QueryName, responseCreator)
 {
     Parameters.Add(TargetKey, target.BencodedString());
 }
Пример #39
0
        private void appendFilterAtom2WhereSb(FltAtomExprData filterAtom, string preffixToAppend, string collName)
        {
            if (filterAtom == null)
            {
                return;
            }
            var fltValue      = filterAtom.Value;
            var isCustomValue = false;

            var pField = filterAtom.Field;// StringUtils.FirstCharacterToLower(filterAtom.Field);

            if (filterAtom.Operator == FilterFieldOperator.Between)
            {
                var filterBigger = filterAtom.Clone() as FltAtomExprData;
                filterBigger.Operator = FilterFieldOperator.GreaterEqualThan;
                filterBigger.Value    = filterBigger.Value.BeforeString(";");
                var filterSmaller = filterAtom.Clone() as FltAtomExprData;
                filterSmaller.Operator = FilterFieldOperator.LessEqualThan;
                filterSmaller.Value    = filterSmaller.Value.AfterString(";");
                var group = Filter.Filter.And(filterBigger, filterSmaller);
                filterExprAppendWhereAndParams(group, preffixToAppend, collName);
                return;
            }

            if (filterAtom.Operator == FilterFieldOperator.In && (filterAtom.Values == null || filterAtom.Values.Count == 0) && filterAtom.Value.IsEmpty())
            {
                filterAtom = Filter.Filter.AlwaysFalse();
            }
            if (filterAtom.Field == "1")
            {
                _whereStringBuilder.Append(preffixToAppend);
                _whereStringBuilder.Append(" (1=" + filterAtom.Value + ")");
                return;
            }

            if (pField == null)
            {
                filterAtom.Field    = "";
                filterAtom.Operator = FilterFieldOperator.IsNull;
            }
            _whereStringBuilder.Append(preffixToAppend);
            _whereStringBuilder.Append("(");



            var fld = pField;

            if (filterAtom.Operator != FilterFieldOperator.Contains &&
                filterAtom.Operator != FilterFieldOperator.StartsWith &&
                filterAtom.Operator != FilterFieldOperator.EndsWith)
            {
                if (collName.IsNotEmpty())
                {
                    _whereStringBuilder.Append(collName);
                    _whereStringBuilder.Append(".");
                }
                _whereStringBuilder.Append(fld);
            }
            else
            {
                fld = $"{collName}.{fld}";
            }

            _whereStringBuilder.Append(" ");
            switch (filterAtom.Operator)
            {
            case FilterFieldOperator.Equal:
                _whereStringBuilder.Append("="); break;

            case FilterFieldOperator.GreaterThan:
                _whereStringBuilder.Append(">"); break;

            case FilterFieldOperator.GreaterEqualThan:
                _whereStringBuilder.Append(">="); break;

            case FilterFieldOperator.In:
                _whereStringBuilder.Append("IN"); break;

            case FilterFieldOperator.LessThan:
                _whereStringBuilder.Append("<"); break;

            case FilterFieldOperator.LessEqualThan:
                _whereStringBuilder.Append("<="); break;

            //In document DB it's different
            //case FilterFieldOperator.Like:
            //case FilterFieldOperator.Contains:
            //case FilterFieldOperator.StartsWith:
            //case FilterFieldOperator.EndsWith:
            //    _whereStringBuilder.Append("LIKE"); break;
            case FilterFieldOperator.NotEqual:
                _whereStringBuilder.Append("<>"); break;

            case FilterFieldOperator.IsNull:
                _whereStringBuilder.Append("IS NULL"); break;

            case FilterFieldOperator.IsNotNull:
                _whereStringBuilder.Append("IS NOT NULL"); break;
            }
            _whereStringBuilder.Append(" ");
            if (filterAtom.Operator == FilterFieldOperator.In)
            {
                _whereStringBuilder.Append("(");
            }

            if (filterAtom.Operator == FilterFieldOperator.In)
            {
                List <string> valuesList = new List <string>();
                if (filterAtom.Values != null)
                {
                    valuesList = filterAtom.Values;
                }
                else
                {
                    valuesList = filterAtom.Value.SplitCharList(';');
                }

                for (int i = 0; i < valuesList.Count; i++)
                {
                    if (i > 0)
                    {
                        _whereStringBuilder.Append(",");
                    }
                    _whereStringBuilder.Append("@");
                    _whereStringBuilder.Append(FieldName2ParamName(pField + i, filterAtom));
                    Parameters.Add(FieldName2ParamName(pField + i, filterAtom), valuesList[i]);
                }
            }
            else if (filterAtom.Operator == FilterFieldOperator.StartsWith ||
                     filterAtom.Operator == FilterFieldOperator.EndsWith ||
                     filterAtom.Operator == FilterFieldOperator.Contains)
            {
                var func = "";
                if (filterAtom.Operator == FilterFieldOperator.StartsWith)
                {
                    func = "STARTSWITH";
                }
                else if (filterAtom.Operator == FilterFieldOperator.EndsWith)
                {
                    func = "ENDSWITH";
                }
                else if (filterAtom.Operator == FilterFieldOperator.Contains)
                {
                    func = "CONTAINS";
                }
                _whereStringBuilder.Append($" {func}({fld},@{FieldName2ParamName(pField, filterAtom)}) ");
                Parameters[FieldName2ParamName(pField, filterAtom)] = fltValue;
            }
            else if (filterAtom.Operator != FilterFieldOperator.IsNull && filterAtom.Operator != FilterFieldOperator.IsNotNull)
            {
                if (!isCustomValue)
                {
                    _whereStringBuilder.Append("@");
                    _whereStringBuilder.Append(FieldName2ParamName(pField, filterAtom));

                    object value = fltValue;

                    if (filterAtom.PropertyType == PropertyType.Integer)
                    {
                        var isNumberTry = fltValue.ToInt(int.MaxValue);
                        if (isNumberTry != int.MaxValue)
                        {
                            value = isNumberTry;
                        }
                    }
                    else if (filterAtom.PropertyType == PropertyType.Float)
                    {
                        var isNumberTry = fltValue.ToDouble(double.NaN);
                        if (isNumberTry != double.NaN)
                        {
                            value = isNumberTry;
                        }
                    }

                    Parameters[FieldName2ParamName(pField, filterAtom)] = value;
                }
                else
                {
                    fltValue = fltValue.Replace("'", "''");
                    _whereStringBuilder.Append(fltValue);
                }
            }

            if (filterAtom.Operator == FilterFieldOperator.In)
            {
                _whereStringBuilder.Append(")");
            }
            _whereStringBuilder.Append(")");
        }
Пример #40
0
 public override SearchVenuesRequest AddQueryParameter(SearchVenuesQueryParameters parameter, string value)
 {
     Parameters.Add(parameter.ToString(), value);
     return(this);
 }
Пример #41
0
 public ParetoFrontAnalyzer()
 {
     Parameters.Add(new ScopeTreeLookupParameter <DoubleArray>("Qualities", "The vector of qualities of each solution."));
     Parameters.Add(new LookupParameter <ResultCollection>("Results", "The result collection to store the front to."));
 }
Пример #42
0
        /// <summary>
        /// Add a parameter with a given name and value.
        /// </summary>
        /// <param name="name">The name of the parameter</param>
        /// <param name="value">The value of the parameter as a FHIR datatype or Resource</param>
        /// <returns>this (Parameters), so you can chain AddParameter calls</returns>
        public SearchParams Add(string name, string value)
        {
            if (name == null)
            {
                throw Error.ArgumentNull(nameof(name));
            }
            if (value == null)
            {
                throw Error.ArgumentNull(nameof(value));
            }

            if (name == SEARCH_PARAM_QUERY)
            {
                Query = nonEmptySingleValue(name, Query, value);
            }
            else if (name == SEARCH_PARAM_TEXT)
            {
                Text = nonEmptySingleValue(name, Text, value);
            }
            else if (name == SEARCH_PARAM_CONTENT)
            {
                Content = nonEmptySingleValue(name, Content, value);
            }
            else if (name == SEARCH_PARAM_COUNT)
            {
                int count;
                if (!Int32.TryParse(value, out count) || count <= 0)
                {
                    throw Error.Format("Invalid {0}: '{1}' is not a positive integer".FormatWith(name, value));
                }
                Count = count;
            }
            else if (name == SEARCH_PARAM_INCLUDE)
            {
                addNonEmpty(name, Include, value);
            }
            else if (name == SEARCH_PARAM_REVINCLUDE)
            {
                addNonEmpty(name, RevInclude, value);
            }
            else if (name.StartsWith(SEARCH_PARAM_SORT + SEARCH_MODIFIERSEPARATOR))
            {
                var order = name.Substring(SEARCH_PARAM_SORT.Length + 1).ToLower();

                if ("ascending".StartsWith(order) && order.Length >= 3)
                {
                    addNonEmptySort(value, SortOrder.Ascending);
                }
                else if ("descending".StartsWith(order) && order.Length >= 4)
                {
                    addNonEmptySort(value, SortOrder.Descending);
                }
                else
                {
                    throw Error.Format("Invalid {0}: '{1}' is not a recognized sort order".FormatWith(SEARCH_PARAM_SORT, order));
                }
            }
            else if (name == SEARCH_PARAM_SORT)
            {
                addNonEmptySort(value, SortOrder.Ascending);
            }
            else if (name == SEARCH_PARAM_SUMMARY)
            {
                SummaryType st = SummaryType.False;
                if (Enum.TryParse(value, ignoreCase: true, result: out st))
                {
                    Summary = st;
                }
                else
                {
                    throw Error.Format("Invalid {0}: '{1}' is not a recognized summary value".FormatWith(name, value));
                }
            }
            else if (name == SEARCH_PARAM_FILTER)
            {
                Filter = nonEmptySingleValue(name, Filter, value);
            }
            else if (name == SEARCH_PARAM_CONTAINED)
            {
                if (SEARCH_CONTAINED_TRUE.Equals(value))
                {
                    Contained = ContainedSearch.True;
                }
                else if (SEARCH_CONTAINED_FALSE.Equals(value))
                {
                    Contained = ContainedSearch.False;
                }
                else if (SEARCH_CONTAINED_BOTH.Equals(value))
                {
                    Contained = ContainedSearch.Both;
                }
                else
                {
                    throw Error.Format("Invalid {0}: '{1}' is not a recognized contained value".FormatWith(name, value));
                }
            }
            else if (name == SEARCH_PARAM_CONTAINEDTYPE)
            {
                if (SEARCH_CONTAINED_TYPE_CONTAINED.Equals(value))
                {
                    ContainedType = ContainedResult.Contained;
                }
                else if (SEARCH_CONTAINED_TYPE_CONTAINER.Equals(value))
                {
                    ContainedType = ContainedResult.Container;
                }
                else
                {
                    throw Error.Format("Invalid {0}: '{1}' is not a recognized containedType value".FormatWith(name, value));
                }
            }
            else if (name == SEARCH_PARAM_ELEMENTS)
            {
                if (String.IsNullOrEmpty(value))
                {
                    throw Error.Format("Invalid {0} value: it cannot be empty".FormatWith(name));
                }
                Elements.AddRange(value.Split(','));
            }
            else
            {
                Parameters.Add(Tuple.Create(name, value));
            }

            return(this);
        }
 private DisqusForumListFollowersRequest(string forum)
 {
     Parameters.Add(new KeyValuePair <string, string>("forum", forum));
 }
Пример #44
0
        public DisqusUserListFollowingForumsRequest User(int userId)
        {
            Parameters.Add(new KeyValuePair <string, string>("user", userId.ToString()));

            return(this);
        }
Пример #45
0
 public AlbaIntraRouteInversionMoveMaker()
     : base()
 {
     Parameters.Add(new LookupParameter <AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to make."));
 }
Пример #46
0
        /// <summary>
        /// Parses an accept header string.
        /// </summary>
        /// <param name="Value">Accept header string</param>
        /// <returns>Parsed items.</returns>
        public static AcceptRecord[] Parse(string Value)
        {
            List <AcceptRecord> Records = new List <AcceptRecord>();
            List <KeyValuePair <string, string> > Parameters = null;
            StringBuilder sb             = new StringBuilder();
            AcceptRecord  Record         = null;
            string        ParameterName  = null;
            string        ParameterValue = null;
            double        q;
            int           State = 0;
            int           Order = 0;

            foreach (char ch in Value)
            {
                switch (State)
                {
                case 0:                         // Item name.
                    if (ch <= 32)
                    {
                        break;
                    }
                    else if (ch == ';' || ch == ',')
                    {
                        Record = new AcceptRecord()
                        {
                            Item  = sb.ToString().Trim(),
                            Order = Order++
                        };
                        sb.Clear();

                        if (ch == ';')
                        {
                            State++;
                        }
                        else
                        {
                            Records.Add(Record);
                            Record = null;
                        }
                    }
                    else
                    {
                        sb.Append(ch);
                    }
                    break;

                case 1:                         // Parameter Name
                    if (ch == '=')
                    {
                        ParameterName = sb.ToString().Trim();
                        sb.Clear();
                        State++;
                    }
                    else if (ch == ';' || ch == ',')
                    {
                        ParameterName = sb.ToString().Trim();
                        sb.Clear();

                        if (Parameters is null)
                        {
                            Parameters = new List <KeyValuePair <string, string> >();
                        }

                        Parameters.Add(new KeyValuePair <string, string>(ParameterName, string.Empty));
                        ParameterName = null;

                        if (ch == ',')
                        {
                            Record.Parameters = Parameters.ToArray();
                            Records.Add(Record);
                            Record     = null;
                            Parameters = null;
                            State      = 0;
                        }
                    }
                    else
                    {
                        sb.Append(ch);
                    }
                    break;

                case 2:                         // Parameter value.
                    if (ch == '"')
                    {
                        State++;
                    }
                    else if (ch == '\'')
                    {
                        State += 3;
                    }
                    else if (ch == ';' || ch == ',')
                    {
                        ParameterValue = sb.ToString().Trim();
                        sb.Clear();

                        if (ParameterName == "q" && CommonTypes.TryParse(ParameterValue, out q))
                        {
                            Record.Quality = q;
                        }
                        else
                        {
                            if (Parameters is null)
                            {
                                Parameters = new List <KeyValuePair <string, string> >();
                            }

                            Parameters.Add(new KeyValuePair <string, string>(ParameterName, ParameterValue));
                        }

                        ParameterName  = null;
                        ParameterValue = null;

                        if (ch == ',')
                        {
                            if (Parameters != null)
                            {
                                Record.Parameters = Parameters.ToArray();
                            }

                            Records.Add(Record);
                            Record     = null;
                            Parameters = null;
                            State      = 0;
                        }
                        else
                        {
                            State--;
                        }
                    }
                    else
                    {
                        sb.Append(ch);
                    }
                    break;

                case 3:                         // "Value"
                    if (ch == '"')
                    {
                        State--;
                    }
                    else if (ch == '\\')
                    {
                        State++;
                    }
                    else
                    {
                        sb.Append(ch);
                    }
                    break;

                case 4:                         // Escape
                    sb.Append(ch);
                    State--;
                    break;

                case 5:                         // 'Value'
                    if (ch == '\'')
                    {
                        State -= 3;
                    }
                    else if (ch == '\\')
                    {
                        State++;
                    }
                    else
                    {
                        sb.Append(ch);
                    }
                    break;

                case 6:                         // Escape
                    sb.Append(ch);
                    State--;
                    break;
                }
            }

            switch (State)
            {
            case 0:
                Record = new AcceptRecord()
                {
                    Item  = sb.ToString().Trim(),
                    Order = Order++
                };
                if (!string.IsNullOrEmpty(Record.Item))
                {
                    Records.Add(Record);
                }
                break;

            case 1:
                ParameterName = sb.ToString().Trim();
                if (!string.IsNullOrEmpty(ParameterName))
                {
                    if (Parameters is null)
                    {
                        Parameters = new List <KeyValuePair <string, string> >();
                    }

                    Parameters.Add(new KeyValuePair <string, string>(ParameterName, string.Empty));
                }

                if (Parameters != null)
                {
                    Record.Parameters = Parameters.ToArray();
                }

                Records.Add(Record);
                break;

            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                ParameterValue = sb.ToString().Trim();

                if (ParameterName == "q" && CommonTypes.TryParse(ParameterValue, out q))
                {
                    Record.Quality = q;
                }
                else
                {
                    if (Parameters is null)
                    {
                        Parameters = new List <KeyValuePair <string, string> >();
                    }

                    Parameters.Add(new KeyValuePair <string, string>(ParameterName, ParameterValue));
                }

                if (Parameters != null)
                {
                    Record.Parameters = Parameters.ToArray();
                }

                Records.Add(Record);
                break;
            }

            Records.Sort(CompareRecords);

            return(Records.ToArray());
        }
 private DisqusForumListMostLikedUsersRequest(string forum) : base()
 {
     Parameters.Add(new KeyValuePair <string, string>("forum", forum));
 }
 public UserDefinedEvaluator()
     : base()
 {
     Parameters.Add(new LookupParameter <DoubleValue>("Quality", "The quality value of the solution."));
 }
Пример #49
0
        private void Initialize()
        {
            #region Create parameters
            Parameters.Add(new ValueLookupParameter <IRandom>("Random", "A pseudo random number generator."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
            Parameters.Add(new LookupParameter <DoubleValue>("Quality", "The value which represents the quality of a solution."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
            Parameters.Add(new LookupParameter <DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
            Parameters.Add(new LookupParameter <BoolValue>("MoveTabu", "The value that indicates if a move is tabu or not."));
            Parameters.Add(new ValueLookupParameter <IntValue>("MaximumIterations", "The maximum number of generations which should be processed."));
            Parameters.Add(new ValueLookupParameter <IntValue>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu"));

            Parameters.Add(new ValueLookupParameter <IOperator>("MoveGenerator", "The operator that generates the moves."));
            Parameters.Add(new ValueLookupParameter <IOperator>("MoveMaker", "The operator that performs a move and updates the quality."));
            Parameters.Add(new ValueLookupParameter <IOperator>("MoveEvaluator", "The operator that evaluates a move."));
            Parameters.Add(new ValueLookupParameter <IOperator>("TabuChecker", "The operator that checks whether a move is tabu."));
            Parameters.Add(new ValueLookupParameter <IOperator>("TabuMaker", "The operator that declares a move tabu."));

            Parameters.Add(new ValueLookupParameter <IOperator>("Analyzer", "The operator used to analyze the solution and moves."));
            Parameters.Add(new ValueLookupParameter <VariableCollection>("Results", "The variable collection where results should be stored."));
            Parameters.Add(new LookupParameter <IntValue>("EvaluatedMoves", "The number of evaluated moves."));
            #endregion

            #region Create operators
            VariableCreator           variableCreator        = new VariableCreator();
            SubScopesProcessor        subScopesProcessor0    = new SubScopesProcessor();
            Assigner                  bestQualityInitializer = new Assigner();
            Placeholder               analyzer1                  = new Placeholder();
            ResultsCollector          resultsCollector1          = new ResultsCollector();
            SubScopesProcessor        solutionProcessor          = new SubScopesProcessor();
            Placeholder               moveGenerator              = new Placeholder();
            UniformSubScopesProcessor moveEvaluationProcessor    = new UniformSubScopesProcessor();
            Placeholder               moveEvaluator              = new Placeholder();
            Placeholder               tabuChecker                = new Placeholder();
            SubScopesCounter          subScopesCounter           = new SubScopesCounter();
            SubScopesSorter           moveQualitySorter          = new SubScopesSorter();
            TabuSelector              tabuSelector               = new TabuSelector();
            ConditionalBranch         emptyNeighborhoodBranch1   = new ConditionalBranch();
            SubScopesProcessor        moveMakingProcessor        = new SubScopesProcessor();
            UniformSubScopesProcessor selectedMoveMakingProcesor = new UniformSubScopesProcessor();
            Placeholder               tabuMaker                  = new Placeholder();
            Placeholder               moveMaker                  = new Placeholder();
            MergingReducer            mergingReducer             = new MergingReducer();
            Placeholder               analyzer2                  = new Placeholder();
            SubScopesRemover          subScopesRemover           = new SubScopesRemover();
            ConditionalBranch         emptyNeighborhoodBranch2   = new ConditionalBranch();
            BestQualityMemorizer      bestQualityUpdater         = new BestQualityMemorizer();
            IntCounter                iterationsCounter          = new IntCounter();
            Comparator                iterationsComparator       = new Comparator();
            ConditionalBranch         iterationsTermination      = new ConditionalBranch();

            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Iterations", new IntValue(0))); // Class TabuSearch expects this to be called Iterations
            variableCreator.CollectedValues.Add(new ValueParameter <BoolValue>("EmptyNeighborhood", new BoolValue(false)));
            variableCreator.CollectedValues.Add(new ValueParameter <ItemList <IItem> >("TabuList", new ItemList <IItem>()));
            variableCreator.CollectedValues.Add(new ValueParameter <VariableCollection>("Memories", new VariableCollection()));
            variableCreator.CollectedValues.Add(new ValueParameter <DoubleValue>("BestQuality", new DoubleValue(0)));

            bestQualityInitializer.Name = "Initialize BestQuality";
            bestQualityInitializer.LeftSideParameter.ActualName  = "BestQuality";
            bestQualityInitializer.RightSideParameter.ActualName = QualityParameter.Name;

            analyzer1.Name = "Analyzer (placeholder)";
            analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;

            resultsCollector1.CopyValue = new BoolValue(false);
            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>("Iterations"));
            resultsCollector1.CollectedValues.Add(new LookupParameter <DoubleValue>("Best Quality", null, "BestQuality"));
            resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;

            moveGenerator.Name = "MoveGenerator (placeholder)";
            moveGenerator.OperatorParameter.ActualName = MoveGeneratorParameter.Name;

            moveEvaluationProcessor.Parallel = new BoolValue(true);

            moveEvaluator.Name = "MoveEvaluator (placeholder)";
            moveEvaluator.OperatorParameter.ActualName = MoveEvaluatorParameter.Name;

            tabuChecker.Name = "TabuChecker (placeholder)";
            tabuChecker.OperatorParameter.ActualName = TabuCheckerParameter.Name;

            subScopesCounter.Name = "Increment EvaluatedMoves";
            subScopesCounter.ValueParameter.ActualName = EvaluatedMovesParameter.Name;

            moveQualitySorter.DescendingParameter.ActualName = MaximizationParameter.Name;
            moveQualitySorter.ValueParameter.ActualName      = MoveQualityParameter.Name;

            tabuSelector.AspirationParameter.Value       = new BoolValue(true);
            tabuSelector.BestQualityParameter.ActualName = "BestQuality";
            tabuSelector.CopySelected = new BoolValue(false);
            tabuSelector.EmptyNeighborhoodParameter.ActualName = "EmptyNeighborhood";
            tabuSelector.MaximizationParameter.ActualName      = MaximizationParameter.Name;
            tabuSelector.MoveQualityParameter.ActualName       = MoveQualityParameter.Name;
            tabuSelector.MoveTabuParameter.ActualName          = MoveTabuParameter.Name;

            moveMakingProcessor.Name = "MoveMaking processor (UniformSubScopesProcessor)";

            emptyNeighborhoodBranch1.Name = "Neighborhood empty?";
            emptyNeighborhoodBranch1.ConditionParameter.ActualName = "EmptyNeighborhood";

            tabuMaker.Name = "TabuMaker (placeholder)";
            tabuMaker.OperatorParameter.ActualName = TabuMakerParameter.Name;

            moveMaker.Name = "MoveMaker (placeholder)";
            moveMaker.OperatorParameter.ActualName = MoveMakerParameter.Name;

            analyzer2.Name = "Analyzer (placeholder)";
            analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;

            subScopesRemover.RemoveAllSubScopes = true;

            bestQualityUpdater.Name = "Update BestQuality";
            bestQualityUpdater.MaximizationParameter.ActualName = MaximizationParameter.Name;
            bestQualityUpdater.QualityParameter.ActualName      = QualityParameter.Name;
            bestQualityUpdater.BestQualityParameter.ActualName  = "BestQuality";

            iterationsCounter.Name      = "Iterations Counter";
            iterationsCounter.Increment = new IntValue(1);
            iterationsCounter.ValueParameter.ActualName = "Iterations";

            iterationsComparator.Name       = "Iterations >= MaximumIterations";
            iterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
            iterationsComparator.LeftSideParameter.ActualName  = "Iterations";
            iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
            iterationsComparator.ResultParameter.ActualName    = "Terminate";

            emptyNeighborhoodBranch2.Name = "Neighborhood empty?";
            emptyNeighborhoodBranch2.ConditionParameter.ActualName = "EmptyNeighborhood";

            iterationsTermination.Name = "Iterations Termination Condition";
            iterationsTermination.ConditionParameter.ActualName = "Terminate";
            #endregion

            #region Create operator graph
            OperatorGraph.InitialOperator = variableCreator;
            variableCreator.Successor     = subScopesProcessor0;
            subScopesProcessor0.Operators.Add(bestQualityInitializer);
            subScopesProcessor0.Successor    = resultsCollector1;
            bestQualityInitializer.Successor = analyzer1;
            analyzer1.Successor         = null;
            resultsCollector1.Successor = solutionProcessor;
            solutionProcessor.Operators.Add(moveGenerator);
            solutionProcessor.Successor          = iterationsCounter;
            moveGenerator.Successor              = moveEvaluationProcessor;
            moveEvaluationProcessor.Operator     = moveEvaluator;
            moveEvaluationProcessor.Successor    = subScopesCounter;
            moveEvaluator.Successor              = tabuChecker;
            tabuChecker.Successor                = null;
            subScopesCounter.Successor           = moveQualitySorter;
            moveQualitySorter.Successor          = tabuSelector;
            tabuSelector.Successor               = emptyNeighborhoodBranch1;
            emptyNeighborhoodBranch1.FalseBranch = moveMakingProcessor;
            emptyNeighborhoodBranch1.TrueBranch  = null;
            emptyNeighborhoodBranch1.Successor   = subScopesRemover;
            moveMakingProcessor.Operators.Add(new EmptyOperator());
            moveMakingProcessor.Operators.Add(selectedMoveMakingProcesor);
            moveMakingProcessor.Successor        = mergingReducer;
            selectedMoveMakingProcesor.Operator  = tabuMaker;
            selectedMoveMakingProcesor.Successor = null;
            tabuMaker.Successor                  = moveMaker;
            moveMaker.Successor                  = null;
            mergingReducer.Successor             = analyzer2;
            analyzer2.Successor                  = null;
            subScopesRemover.Successor           = null;
            iterationsCounter.Successor          = iterationsComparator;
            iterationsComparator.Successor       = emptyNeighborhoodBranch2;
            emptyNeighborhoodBranch2.TrueBranch  = null;
            emptyNeighborhoodBranch2.FalseBranch = iterationsTermination;
            emptyNeighborhoodBranch2.Successor   = null;
            iterationsTermination.TrueBranch     = null;
            iterationsTermination.FalseBranch    = solutionProcessor;
            #endregion
        }
Пример #50
0
 public VRPMoveMaker()
   : base() {
   Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
   Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
   Parameters.Add(new LookupParameter<DoubleValue>("MovePenalty", "The penalty applied to the move."));
 }
Пример #51
0
        public void SetAliases()
        {
            _aliases = null;

            var objs = new HashSet <IQueryElement>();

            Parameters.Clear();

            foreach (var element in QueryVisitor.FindOnce <IQueryElement>(this))
            {
                switch (element.ElementType)
                {
                case EQueryElementType.SqlParameter:
                {
                    var p = (ISqlParameter)element;

                    if (p.IsQueryParameter)
                    {
                        if (!objs.Contains(element))
                        {
                            objs.Add(element);
                            p.Name = GetAlias(p.Name, "p");
                        }

                        Parameters.Add(p);
                    }
                    else
                    {
                        IsParameterDependent = true;
                    }
                }

                break;

                case EQueryElementType.Column:
                {
                    if (!objs.Contains(element))
                    {
                        objs.Add(element);

                        var c = (IColumn)element;

                        if (c.Alias != "*")
                        {
                            c.Alias = GetAlias(c.Alias, "c");
                        }
                    }
                }

                break;

                case EQueryElementType.TableSource:
                {
                    var table = (ITableSource)element;

                    if (!objs.Contains(table))
                    {
                        objs.Add(table);
                        table.Alias = GetAlias(table.Alias, "t");
                    }
                }

                break;

                case EQueryElementType.SqlQuery:
                {
                    var sql = (ISelectQuery)element;

                    if (sql.HasUnion)
                    {
                        for (var i = 0; i < sql.Select.Columns.Count; i++)
                        {
                            var col = sql.Select.Columns[i];

                            var index = i;
                            sql.Unions.ForEach(
                                node =>
                                {
                                    var union = node.Value.SelectQuery.Select;

                                    objs.Remove(union.Columns[index]);

                                    union.Columns[index].Alias = col.Alias;
                                });
                        }
                    }

                    break;
                }
                }
            }
        }
        public DisqusForumListFollowersRequest Cursor(string cursor)
        {
            Parameters.Add(new KeyValuePair <string, string>("cursor", cursor));

            return(this);
        }
Пример #53
0
        public RobustTabooSearch()
        {
            Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The analyzers that are applied after each iteration.", new MultiAnalyzer()));
            Parameters.Add(new FixedValueParameter <IntValue>("Seed", "The seed value of the random number generator.", new IntValue(0)));
            Parameters.Add(new FixedValueParameter <BoolValue>("SetSeedRandomly", "True whether the seed should be set randomly for each run, false if it should be fixed.", new BoolValue(true)));
            Parameters.Add(new FixedValueParameter <IntValue>("MaximumIterations", "The number of iterations that the algorithm should run.", new IntValue(10000)));
            Parameters.Add(new FixedValueParameter <IntValue>("MinimumTabuTenure", "The minimum tabu tenure.", new IntValue(10)));
            Parameters.Add(new FixedValueParameter <IntValue>("MaximumTabuTenure", "The maximum tabu tenure.", new IntValue(20)));
            Parameters.Add(new FixedValueParameter <BoolValue>("UseAlternativeAspiration", "True if the alternative aspiration condition should be used that takes moves that have not been made for some time above others.", new BoolValue(false)));
            Parameters.Add(new FixedValueParameter <IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition.", new IntValue(int.MaxValue)));
            Parameters.Add(new FixedValueParameter <BoolValue>("TerminateOnOptimalSolution", "True when the algorithm should stop if it reached a quality equal or smaller to the BestKnownQuality.", new BoolValue(false)));
            Parameters.Add(new FixedValueParameter <BoolValue>("UseNewTabuTenureAdaptionScheme", @"In an updated version of his implementation, Eric Taillard introduced a different way to change the tabu tenure.
Instead of setting it uniformly between min and max, it will be set between 0 and max according to a right-skewed distribution.
Set this option to false if you want to optimize using the earlier 1991 version, and set to true if you want to optimize using the newer version.
Please note that the MinimumTabuTenure parameter has no effect in the new version.", new BoolValue(true)));

            TerminateOnOptimalSolutionParameter.Hidden = true;

            qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
            qualityAnalyzer.ResultsParameter.ActualName = "Results";
            AnalyzerParameter.Value.Operators.Add(qualityAnalyzer);

            RandomCreator randomCreator = new RandomCreator();

            randomCreator.RandomParameter.ActualName          = "Random";
            randomCreator.SeedParameter.Value                 = null;
            randomCreator.SeedParameter.ActualName            = SeedParameter.Name;
            randomCreator.SetSeedRandomlyParameter.Value      = null;
            randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;

            VariableCreator variableCreator = new VariableCreator();

            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Iterations", new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("EvaluatedSolutions", new IntValue(1)));
            variableCreator.CollectedValues.Add(new ValueParameter <DoubleValue>("EvaluatedSolutionEquivalents", new DoubleValue(1)));

            ResultsCollector resultsCollector = new ResultsCollector();

            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Iterations", "The actual iteration."));
            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("EvaluatedSolutions", "Number of evaluated solutions."));

            solutionsCreator = new SolutionsCreator();
            solutionsCreator.NumberOfSolutions = new IntValue(1);

            Placeholder analyzer = new Placeholder();

            analyzer.Name = "(Analyzer)";
            analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;

            UniformSubScopesProcessor ussp = new UniformSubScopesProcessor();

            mainOperator = new RobustTabooSeachOperator();
            mainOperator.AlternativeAspirationTenureParameter.ActualName = AlternativeAspirationTenureParameter.Name;
            mainOperator.BestQualityParameter.ActualName                  = "BestSoFarQuality";
            mainOperator.IterationsParameter.ActualName                   = "Iterations";
            mainOperator.LastMoveParameter.ActualName                     = "LastMove";
            mainOperator.MaximumIterationsParameter.ActualName            = MaximumIterationsParameter.Name;
            mainOperator.MaximumTabuTenureParameter.ActualName            = MaximumTabuTenureParameter.Name;
            mainOperator.MinimumTabuTenureParameter.ActualName            = MinimumTabuTenureParameter.Name;
            mainOperator.MoveQualityMatrixParameter.ActualName            = "MoveQualityMatrix";
            mainOperator.RandomParameter.ActualName                       = "Random";
            mainOperator.ResultsParameter.ActualName                      = "Results";
            mainOperator.ShortTermMemoryParameter.ActualName              = "ShortTermMemory";
            mainOperator.UseAlternativeAspirationParameter.ActualName     = UseAlternativeAspirationParameter.Name;
            mainOperator.EvaluatedSolutionsParameter.ActualName           = "EvaluatedSolutions";
            mainOperator.EvaluatedSolutionEquivalentsParameter.ActualName = "EvaluatedSolutionEquivalents";

            ConditionalBranch qualityStopBranch = new ConditionalBranch();

            qualityStopBranch.Name = "Terminate on optimal quality?";
            qualityStopBranch.ConditionParameter.ActualName = "TerminateOnOptimalSolution";

            Comparator qualityComparator = new Comparator();

            qualityComparator.Comparison = new Comparison(ComparisonType.Greater);
            qualityComparator.LeftSideParameter.ActualName  = "BestQuality";
            qualityComparator.RightSideParameter.ActualName = "BestKnownQuality";
            qualityComparator.ResultParameter.ActualName    = "ContinueByQuality";

            ConditionalBranch continueByQualityBranch = new ConditionalBranch();

            continueByQualityBranch.ConditionParameter.ActualName = "ContinueByQuality";

            IntCounter iterationsCounter = new IntCounter();

            iterationsCounter.ValueParameter.ActualName = "Iterations";
            iterationsCounter.Increment = new IntValue(1);

            Comparator comparator = new Comparator();

            comparator.Name = "Iterations < MaximumIterations ?";
            comparator.LeftSideParameter.ActualName  = "Iterations";
            comparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
            comparator.Comparison = new Comparison(ComparisonType.Less);
            comparator.ResultParameter.ActualName = "ContinueByIteration";

            ConditionalBranch continueByIterationBranch = new ConditionalBranch();

            continueByIterationBranch.ConditionParameter.ActualName = "ContinueByIteration";

            OperatorGraph.InitialOperator = randomCreator;
            randomCreator.Successor       = variableCreator;
            variableCreator.Successor     = resultsCollector;
            resultsCollector.Successor    = solutionsCreator;
            solutionsCreator.Successor    = analyzer;
            analyzer.Successor            = ussp;
            ussp.Operator  = mainOperator;
            ussp.Successor = qualityStopBranch;
            qualityStopBranch.FalseBranch       = iterationsCounter;
            qualityStopBranch.TrueBranch        = qualityComparator;
            qualityStopBranch.Successor         = null;
            qualityComparator.Successor         = continueByQualityBranch;
            continueByQualityBranch.TrueBranch  = iterationsCounter;
            continueByQualityBranch.FalseBranch = null;
            continueByQualityBranch.Successor   = null;
            iterationsCounter.Successor         = comparator;
            comparator.Successor = continueByIterationBranch;
            continueByIterationBranch.TrueBranch  = analyzer;
            continueByIterationBranch.FalseBranch = null;
            continueByIterationBranch.Successor   = null;

            RegisterEventHandlers();
            Problem = new QuadraticAssignmentProblem();
        }
        public DisqusForumListFollowersRequest Limit(int limit)
        {
            Parameters.Add(new KeyValuePair <string, string>("limit", limit.ToString()));

            return(this);
        }
Пример #55
0
Файл: Data.cs Проект: dpx3/Q4
 public Data()
 {
     Parameters.Add(new Parameter("On/Off", "true", "Boolean"));
     Parameters.Add(new Parameter("Elevation", "100", "String"));
 }
        public DisqusForumListFollowersRequest SinceId(int sinceId)
        {
            Parameters.Add(new KeyValuePair <string, string>("since_id", sinceId.ToString()));

            return(this);
        }
Пример #57
0
 public ScheduleCreator()
     : base()
 {
     Parameters.Add(new LookupParameter <IScheduleEncoding>("ScheduleEncoding", "The new scheduling solutioncandidate."));
 }
 public SingleObjectiveMoveMaker()
 {
     Parameters.Add(new LookupParameter <IEncoding>("Encoding", "An item that holds the problem's encoding."));
     Parameters.Add(new LookupParameter <DoubleValue>("Quality", "The quality of the parameter vector."));
     Parameters.Add(new LookupParameter <DoubleValue>("MoveQuality", "The quality of the move."));
 }
        public DisqusForumListFollowersRequest Order(DisqusOrder order)
        {
            Parameters.Add(new KeyValuePair <string, string>("order", order.ToString().ToLower()));

            return(this);
        }
Пример #60
0
 public CVRPEvaluator()
 {
     Parameters.Add(new LookupParameter <DoubleValue>("Overload", "The overload."));
 }