protected override void EvaluateMove() { PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue; PotvinEncoding newSolution = CustomerRelocationMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding; PotvinCustomerRelocationMoveMaker.Apply(newSolution, move, ProblemInstance); UpdateEvaluation(newSolution); //Apply memory, only if move is worse if (MoveQualityParameter.ActualValue.Value >= QualityParameter.ActualValue.Value) { VariableCollection memory = MemoriesParameter.ActualValue; string key = AdditionFrequencyMemoryKeyParameter.Value.Value; if (memory != null && memory.ContainsKey(key)) { ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = memory[key].Value as ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>; PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City); if (additionFrequency.ContainsKey(attr)) { int frequency = additionFrequency[attr].Value; double quality = MoveQualityParameter.ActualValue.Value; MoveQualityParameter.ActualValue.Value += LambdaParameter.Value.Value * quality * frequency; } } } }
public TypeDescription Get(string typeName) { if (!string.IsNullOrEmpty(typeName)) { if (Names.ContainsKey(typeName)) { return(Names[typeName]); } if (typeName.StartsWith(SystemNullable)) { var optionalDescription = Get(typeName.Substring(SystemNullable.Length, typeName.Length - 1 - SystemNullable.Length)). Clone(); optionalDescription.IsOptional = true; return(optionalDescription); } if (typeName.StartsWith(SystemIEnumerable)) { var optionalDescription = Get(typeName.Substring(SystemIEnumerable.Length, typeName.Length - 1 - SystemIEnumerable.Length)) .Clone(); optionalDescription.IsCollection = true; optionalDescription.Description = string.Format("Collection of {0}s", optionalDescription.Description); return(optionalDescription); } } return(new TypeDescription(typeName, string.Empty)); }
public IEnumerable <SecurityWrapper> SetAccessToWebItems(IEnumerable <ItemKeyValuePair <String, Boolean> > items) { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var itemList = new ItemDictionary <String, Boolean>(); foreach (ItemKeyValuePair <String, Boolean> item in items) { if (!itemList.ContainsKey(item.Key)) { itemList.Add(item.Key, item.Value); } } var defaultPageSettings = StudioDefaultPageSettings.Load(); foreach (var item in itemList) { Guid[] subjects = null; var productId = new Guid(item.Key); if (item.Value) { var webItem = WebItemManager.Instance[productId] as IProduct; if (webItem != null) { var productInfo = WebItemSecurity.GetSecurityInfo(item.Key); var selectedGroups = productInfo.Groups.Select(group => group.ID).ToList(); var selectedUsers = productInfo.Users.Select(user => user.ID).ToList(); selectedUsers.AddRange(selectedGroups); if (selectedUsers.Count > 0) { subjects = selectedUsers.ToArray(); } } } else if (productId == defaultPageSettings.DefaultProductID) { (defaultPageSettings.GetDefault() as StudioDefaultPageSettings).Save(); } WebItemSecurity.SetSecurity(item.Key, item.Value, subjects); } MessageService.Send(Request, MessageAction.ProductsListUpdated); return(GetWebItemSecurityInfo(itemList.Keys.ToList())); }
protected override void PerformMove() { PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue; PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding; Apply(newSolution, move, ProblemInstance); newSolution.Repair(); VRPToursParameter.ActualValue = newSolution; //reset move quality VRPEvaluation eval = ProblemInstance.Evaluate(newSolution); MoveQualityParameter.ActualValue.Value = eval.Quality; //update memory VariableCollection memory = MemoriesParameter.ActualValue; string key = AdditionFrequencyMemoryKeyParameter.Value.Value; if (memory != null) { if (!memory.ContainsKey(key)) { memory.Add(new Variable(key, new ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>())); } ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = memory[key].Value as ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>; PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City); if (!additionFrequency.ContainsKey(attr)) { additionFrequency[attr] = new IntValue(0); } additionFrequency[attr].Value++; } }
public IEnumerable <SecurityWrapper> SetAccessToWebItems(IEnumerable <ItemKeyValuePair <String, Boolean> > items) { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var itemList = new ItemDictionary <String, Boolean>(); foreach (ItemKeyValuePair <String, Boolean> item in items) { if (!itemList.ContainsKey(item.Key)) { itemList.Add(item.Key, item.Value); } } foreach (var item in itemList) { Guid[] subjects = null; if (item.Value) { var webItem = WebItemManager.Instance[new Guid(item.Key)] as IProduct; if (webItem != null) { var productInfo = WebItemSecurity.GetSecurityInfo(item.Key); var selectedGroups = productInfo.Groups.Select(group => group.ID).ToList(); var selectedUsers = productInfo.Users.Select(user => user.ID).ToList(); selectedUsers.AddRange(selectedGroups); if (selectedUsers.Count > 0) { subjects = selectedUsers.ToArray(); } } } WebItemSecurity.SetSecurity(item.Key, item.Value, subjects); } return(GetWebItemSecurityInfo(itemList.Keys.ToList())); }
/// <summary> /// Determines whether [contains] [the specified field name]. /// </summary> /// <param name="fieldName">Name of the field.</param> /// <returns><c>true</c> if [contains] [the specified field name]; otherwise, <c>false</c>.</returns> public bool Contains(string fieldName) { return(ItemDictionary.ContainsKey(fieldName)); }
public IEnumerable<SecurityWrapper> SetAccessToWebItems(IEnumerable<ItemKeyValuePair<String, Boolean>> items) { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var itemList = new ItemDictionary<String, Boolean>(); foreach (ItemKeyValuePair<String, Boolean> item in items) { if (!itemList.ContainsKey(item.Key)) itemList.Add(item.Key, item.Value); } foreach (var item in itemList) { Guid[] subjects = null; if (item.Value) { var webItem = WebItemManager.Instance[new Guid(item.Key)] as IProduct; if (webItem != null) { var productInfo = WebItemSecurity.GetSecurityInfo(item.Key); var selectedGroups = productInfo.Groups.Select(group => group.ID).ToList(); var selectedUsers = productInfo.Users.Select(user => user.ID).ToList(); selectedUsers.AddRange(selectedGroups); if (selectedUsers.Count > 0) { subjects = selectedUsers.ToArray(); } } } WebItemSecurity.SetSecurity(item.Key, item.Value, subjects); } return GetWebItemSecurityInfo(itemList.Keys.ToList()); }