Exemplo n.º 1
0
        public void MergeToBests(IEntityList entities)
        {
            IEntityList travelers = new EntityList(entities.Count);
            bool        anyMerged = false;

            for (int e = 0; e < entities.Count; e++)
            {
                if (entities[e].Fitness.IsLethal())
                {
                    continue;
                }

                bool merged = FitnessComparer.MergeToBests(Algorithm.Population.Bests, entities[e]);
                if (merged)
                {
                    travelers.Add(entities[e]);
                    var timeString = DateTime.Now.ToString("HH:mm:ss.ffff");
                    Debug.WriteLine(timeString + " " + entities[e].ToString());
                    var stat = Algorithm.Population.FitnessStatistics.StatisticVariables[0];
                    Debug.WriteLine($"{timeString} Mean: {stat.Mean}, Deviation: {stat.Deviation}");
                    anyMerged = true;
                }
            }

            if (anyMerged && NewEntityMergedToBest != null)
            {
                NewEntityMergedToBest(Algorithm.Population.Bests);
            }

            if (LaunchTravelers != null && travelers.Count > 0)
            {
                LaunchTravelers(travelers, TravelerTypes.Best);
            }
        }
Exemplo n.º 2
0
 public virtual void AddEntitiesToPopulation(IPopulation population, IEntityList entities)
 {
     for (int i = 0; i < entities.Count; i++)
     {
         population.Add(entities[i]);
     }
 }
Exemplo n.º 3
0
        private void purgerLeStockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //purge stock
            IEntityList stocks = _Context.EntityManager.GetEntityList("_STOCK");

            stocks.Fill(false);
            DialogResult res = MessageBox.Show("Do you really want to destroy all sheets from the stock?", "Warnig", MessageBoxButtons.OKCancel);

            if (res == DialogResult.OK)
            {
                foreach (IEntity stock in stocks)
                {
                    stock.Delete();
                }


                IEntityList formats = _Context.EntityManager.GetEntityList("_SHEET");
                formats.Fill(false);

                foreach (IEntity format in formats)
                {
                    format.Delete();
                }
            }
        }
Exemplo n.º 4
0
    public override void OnBeforeSendToWorkshopEvent(IContext context, BeforeSendToWorkshopArgs args)
    {
        IEntity nesting = args.NestingEntity;
        string  cle     = nesting.GetFieldValueAsString("_REFERENCE");

        #region création stock CFAO

        string nestingName         = nesting.GetFieldValueAsString("_NAME");
        int    nestingMultiplicity = nesting.GetFieldValueAsInt("_QUANTITY");

        int         a          = 0;
        IEntityList _sheetList = context.EntityManager.GetEntityList("_SHEET");
        _sheetList.Fill(false);
        var sheetList = _sheetList.Where(p => p.GetFieldValueAsString("_NAME").Contains(nestingName));
        foreach (IEntity sheet in sheetList)
        {
            for (int i = 0; i < nestingMultiplicity; i++)
            {
                IEntity newStock = context.EntityManager.CreateEntity("_STOCK");
                newStock.SetFieldValue("_SHEET", sheet.Id32);
                newStock.SetFieldValue("_NAME", i.ToString());
                newStock.SetFieldValue("AF_STOCK_NAME", sheet.GetFieldValueAsString("_REFERENCE") + "-" + (i + 1).ToString("00"));
                newStock.SetFieldValue("_QUANTITY", 1);
                newStock.SetFieldValue("AF_STOCK_CFAO", true);
                newStock.Save();
            }
        }

        #endregion  création stock CFAO
    }
Exemplo n.º 5
0
        public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations)
        {
            if (LeftRef is PqlInteger || LeftRef is PqlString)
            {
                LeftArgs = LoadSingleLeftArg(pkb);
            }
            else if (LeftRef is PqlEmptyArg)
            {
                LeftArgs = LoadLeftArgs(pkb);
            }
            else
            {
                PqlDeclaration declaration = declarations.GetDeclarationBySynonym((LeftRef as PqlSynonym).Name);
                LeftArgs          = declaration.EntityList;
                LeftArgs.ListName = (LeftRef as PqlSynonym).Name;
            }

            if (RightRef is PqlInteger || RightRef is PqlString)
            {
                RightArgs = LoadSingleRightArg(pkb);
            }
            else if (RightRef is PqlEmptyArg)
            {
                RightArgs = LoadRightArgs(pkb);
            }
            else
            {
                PqlDeclaration declaration = declarations.GetDeclarationBySynonym((RightRef as PqlSynonym).Name);
                RightArgs          = declaration.EntityList;
                RightArgs.ListName = (RightRef as PqlSynonym).Name;
            }
        }
        public override IEntityList Replace(IPopulation targetPopulation, IEntityList offspring, IEntityList parents, IPopulation sourcePopulation)
        {
            var inserted       = new EntityList(1);
            var populationSize = Parameters.GetValue(Algorithm.ParameterNames.PopulationSize);

            //TODO: FitnessComparer.SelectWorst, SelectBest

            if (offspring.Count == 0)
            {
                return(inserted);
            }

            var entityToRemove = FitnessComparer.Dominates(parents[0].Fitness, parents[1].Fitness) ? parents[0] : parents[1];
            var entityToAdd    = (offspring.Count > 1 && FitnessComparer.Dominates(offspring[0].Fitness, offspring[1].Fitness)) ? offspring[1] : offspring[0];

            if (FitnessComparer.Dominates(entityToRemove.Fitness, entityToAdd.Fitness))
            {
                targetPopulation.Add(entityToAdd);
                inserted.Add(entityToAdd);

                if (sourcePopulation.Count > populationSize)
                {
                    sourcePopulation.Remove(entityToRemove);
                }
            }

            return(inserted);
        }
Exemplo n.º 7
0
        /// <summary>
        /// recupere la reference du premier placement selectionné dans les placements a copuper
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AfterSend_Click_1(object sender, EventArgs e)
        {
            AF_JOHN_DEERE.JohnDeere_DoOnAction_AfterSendToWorkshop doonaction = new JohnDeere_DoOnAction_AfterSendToWorkshop();
            string stage = "_TO_CUT_NESTING";

            JohnDeere_Param.GetlistParam(_Context);
            IEntitySelector nestingselector = null;

            nestingselector = new EntitySelector();

            //entity type pointe sur la list d'objet du model
            nestingselector.Init(_Context, _Context.Kernel.GetEntityType(stage));
            nestingselector.MultiSelect = true;

            if (nestingselector.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (IEntity selection in nestingselector.SelectedEntity)
                {
                    string filename = selection.GetFieldValueAsString("_REFERENCE");
                    string material = selection.GetFieldValueAsEntity("_MATERIAL").GetFieldValueAsString("_NAME");

                    IEntityList nestinglist = _Context.EntityManager.GetEntityList(stage, "_REFERENCE", ConditionOperator.Equal, filename);
                    nestinglist.Fill(false);
                    doonaction.execute(nestinglist);
                }
            }
        }
Exemplo n.º 8
0
        public IEntityList Evaluate(IEntityList entityList)
        {
            if (entityList.Count == 0)
            {
                return(entityList);
            }

            IEntityList evaluatedEntities;

            if (Evaluator == null)
            {
                evaluatedEntities = new EntityList(entityList.Count);
                for (int e = 0; e < entityList.Count; e++)
                {
                    var entityWithKey = new Dictionary <MultiKey, IEntity> {
                        { IslandKey, entityList[e] }
                    };
                    var decodedEntity = LocalEvaluator.Decode(IslandKey, entityWithKey);
                    evaluatedEntities.Add(decodedEntity);
                }
            }
            else
            {
                evaluatedEntities = Evaluator.Ask(entityList).GetAwaiter().GetResult() as IEntityList;
            }
            return(evaluatedEntities);
        }
Exemplo n.º 9
0
        protected IEntityList SelectParents(IEntityList entities, int count)
        {
            var selector = Engine.Selections.GetOne();
            var parents  = selector.Select(entities, count);

            return(parents);
        }
Exemplo n.º 10
0
        public void AddTableData(IEntityList list, string textName = null, string valueName = null)
        {
            this.Items.Clear();
            if (list.Count == 0)
            {
                return;
            }

            var eop = EntityFactory.CreateOperate(list[0].GetType());
            var fs  = eop.FieldNames.ToArray();

            if (textName == null)
            {
                textName = fs[1];
            }
            if (valueName == null)
            {
                valueName = fs[0];
            }
            foreach (var entity in list)
            {
                this.Items.Add(new ListItem(entity[textName] + "", entity[valueName] + ""));
            }
            this.DataBind();
        }
Exemplo n.º 11
0
        public static IEntityList SetField(IEntityList list)
        {
            if (list == null || list.Count < 1)
            {
                return(list);
            }

            var entityType = list[0].GetType();
            var factory    = EntityFactory.CreateOperate(entityType);
            var fs         = factory.AdditionalFields;

            if (fs.Count > 0)
            {
                foreach (EntityBase entity in list)
                {
                    if (entity != null)
                    {
                        foreach (var item in fs)
                        {
                            entity.Addition.SetField(item);
                        }
                    }
                }
            }

            return(list);
        }
Exemplo n.º 12
0
        private IEntity SelectOne(IEntityList entities, int tournamentSize)
        {
            var index = Random.GetInt(0, entities.Count);
            var best  = entities[index];

            for (int i = 1; i < tournamentSize; i++)
            {
                index = Random.GetInt(0, entities.Count);
                var next             = entities[index];
                var comparisonResult = FitnessComparer.Compare(best.Fitness, next.Fitness);
                if (comparisonResult > 0)
                {
                    next.Fitness.TournamentWinner++;
                    best.Fitness.TournamentLoser++;
                    best = next;
                }
                else
                {
                    best.Fitness.TournamentWinner++;
                    next.Fitness.TournamentLoser++;
                }
            }

            return(best);
        }
Exemplo n.º 13
0
        /// <summary>
        /// boite de dialogue quote de selection des devis
        /// </summary>
        /// <param name="quoteNumberReference"></param>
        /// <returns></returns>
        public bool GetQuoteList(out string JsonQuoteList)
        {
            JsonQuoteList = "";
            if (_Context != null)
            {
                IEntityList quoteEntityList = null;
                quoteEntityList = _Context.EntityManager.GetEntityList("_QUOTE_SENT");



                if (quoteEntityList != null)
                {
                    //string quoteReference = quoteEntityList.GetFieldValueAsString("_REFERENCE");
                    //long.TryParse(quoteReference, out JsonQuoteList);
                    foreach (IEntity quoteentity in quoteEntityList)
                    {
                        string reference = quoteentity.GetFieldValueAsString("_REFERENCE");
                        //string user = quoteentity.GetFieldValueAsString("_REFERENCE");
                        //string date = quoteentity.GetFieldValueAsString("_REFERENCE");
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 14
0
 public virtual void RemoveEntitiesFromPopulation(IPopulation population, IEntityList entities)
 {
     for (int i = 0; i < entities.Count; i++)
     {
         population.Remove(entities[i]);
     }
 }
Exemplo n.º 15
0
 public World(IEntityUpdater <Player> playerUpdater, IRegionRepository regionRepository, IEntityList <Player> playerEntityList)
 {
     _playerUpdater           = playerUpdater;
     RegionRepository         = regionRepository;
     _playerEntityList        = playerEntityList;
     _cancellationTokenSource = new CancellationTokenSource();
     _cancellationToken       = _cancellationTokenSource.Token;
 }
Exemplo n.º 16
0
 public BindingNode(IEntity entity, IEntityList entityList)
 {
     Entity     = entity;
     EntityList = entityList;
     RightNodes = new List <BindingNode>();
     LeftNodes  = new List <BindingNode>();
     OneWay     = false;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Libera a instancia.
 /// </summary>
 /// <param name="disposing"></param>
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     _linkInfo = null;
     _child    = null;
     _childFromModelCreator = null;
     _ignoreChildItems.Clear();
 }
Exemplo n.º 18
0
        protected override IEntityList LoadSingleRightArg(IProgramKnowledgeBase pkb)
        {
            IEntity     entity = pkb.Statements.GetEntityByAttribute((RightRef as PqlInteger).Value);
            IEntityList result = ImplementationFactory.CreateEntityList();

            result.AddEntity(entity);
            return(result);
        }
Exemplo n.º 19
0
        protected override IEntityList LoadSingleLeftArg(IProgramKnowledgeBase pkb)
        {
            IEntity     entity = pkb.Procedures.GetEntityByAttribute((LeftRef as PqlString).Value);
            IEntityList result = ImplementationFactory.CreateEntityList();

            result.AddEntity(entity);
            return(result);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Erzeugt eine neue Instanz einer ChunkColumn.
 /// </summary>
 public ChunkColumn(IPlanet planet)
 {
     Heights           = new int[Chunk.CHUNKSIZE_X, Chunk.CHUNKSIZE_Y];
     entities          = new EntityList(this);
     entitieSemaphore  = new LockSemaphore(1, 1);
     DefinitionManager = TypeContainer.Get <IDefinitionManager>();
     Planet            = planet;
     globalChunkCache  = planet.GlobalChunkCache;
 }
Exemplo n.º 21
0
        protected IEntityList Evaluate(IEntityList population)
        {
            if (population.Count == 0)
            {
                return(population);
            }

            return(_evaluate(population));
        }
Exemplo n.º 22
0
        public void LaunchTravelers(IEntityList entityList, TravelerTypes travelerType)
        {
            //for (int e = 0; e < entityList.Count;e++)
            //{
            var traveler = new Travel(entityList, travelerType);

            Starter.Tell(traveler);
            //}
        }
Exemplo n.º 23
0
        /// <summary>从数据读写器加载数据。无数据时返回空集合而不是null。</summary>
        /// <param name="dr">数据读写器</param>
        /// <returns>实体数组</returns>
        public IEntityList LoadData(IDataReader dr)
        {
            //if (dr == null) return null;

            //// 先移到第一行,要取字段名等信息
            //if (!dr.Read()) return null;

            // 准备好实体列表
            IEntityList list = TypeX.CreateInstance(typeof(EntityList <>).MakeGenericType(EntityType)) as IEntityList;

            if (dr == null)
            {
                return(list);
            }

            // 先移到第一行,要取字段名等信息
            if (!dr.Read())
            {
                return(list);
            }

            List <FieldItem> ps   = new List <FieldItem>();
            List <String>    exts = new List <String>();

            for (int i = 0; i < dr.FieldCount; i++)
            {
                String    name = dr.GetName(i);
                FieldItem fi   = null;
                if (FieldItems.TryGetValue(name, out fi))
                {
                    ps.Add(fi);
                }
                else
                {
                    exts.Add(name);
                }
            }

            // 遍历每一行数据,填充成为实体
            do
            {
                // 由实体操作者创建实体对象,因为实体操作者可能更换
                IEntity entity = Factory.Create();
                foreach (FieldItem item in ps)
                {
                    SetValue(entity, item.Name, item.Type, dr[item]);
                }

                foreach (String item in exts)
                {
                    SetValue(entity, item, null, dr[item]);
                }

                list.Add(entity);
            } while (dr.Read());
            return(list);
        }
Exemplo n.º 24
0
 public bool Resolve(IEntityList entities)
 {
     this.Uuid     = entities.FindUuidByName(Name)?.Uuid;
     this.Resolved = this.Uuid != null;
     if (this.Resolved)
     {
         Targeter.IgnoreList.Add(this.Uuid);
     }
     return(this.Resolved);
 }
Exemplo n.º 25
0
 public void Add(IEntityList <T> entityList)
 {
     if (entityList != null)
     {
         foreach (T entity in entityList)
         {
             Add(entity);
         }
     }
 }
Exemplo n.º 26
0
        public object ReadRowSet(IRowReader reader)
        {
            IEntityList list = CreateObjectList();

            while (reader.Read())
            {
                list.Add(ReadRow(reader));
            }
            return(list);
        }
Exemplo n.º 27
0
 public void AddTableData(IEntityList list, string textName, string valueName)
 {
     this.Items.Clear();
     this.Items.Add(new ListItem("请选择     ", "0"));
     foreach (var entity in list)
     {
         this.Items.Add(new ListItem(entity[textName] + "", entity[valueName] + ""));
     }
     this.DataBind();
 }
Exemplo n.º 28
0
        public IEntityList Sum(IEntityList otherEntityList)
        {
            EntityList entityList = otherEntityList as EntityList;

            foreach (IEntity entity in entityList)
            {
                AddEntity(entity);
            }
            return(this);
        }
Exemplo n.º 29
0
        public IEntityList Mutate(IEntityList entities)
        {
            var result = new EntityList(entities.Count);

            for (int i = 0; i < entities.Count; i++)
            {
                var mutated = MutateEntity(entities[i]);
                result.Add(mutated);
            }
            return(result);
        }
Exemplo n.º 30
0
        public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
        {
            List <IEntityList <IEntity> > bigList = AddEntitiesToList(info.GetMatch(), 0, new EntityList <IEntity>());

            for (int i = 0; i < bigList.Count; i++)
            {
                IEntityList <ITrueEntity> oneList             = bigList[i].ConvertToTrueEntityList();
                SubpropertyRelationship   subpropertyRelation = new SubpropertyRelationship(oneList[0] as IPropertyEntity, oneList[1] as IPropertyEntity);
                builder.Add(subpropertyRelation);
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// 获取分页事件所需要的当前数据
        /// </summary>
        public virtual void GetData()
        {
            //开启分页的情况下
            if (ControlParams.IsEnablePaging)
            {
                winPage.RecordCount = EntityOper.FindCount(cutSql, "", "", 0, 0);//获取当前查询的记录总数
                btList = EntityOper.FindAll(cutSql, "", "", (winPage.PageIndex - 1) * winPage.PageSize,
                                            winPage.PageSize);
                //更新分页显示数据

            }
            else //不需要分页的情况下
                btList = EntityOper.FindAll(cutSql, "", "", 0, 0);           
            ArrayList list = new ArrayList();
            for (int i = 0; i < btList.Count; i++) list.Add(btList[i]);            
            dgv.DataSource = list;
            //每次移除不需要的列
            if (ControlParams.DeleteColumnsName !=null )
            {
                foreach (string item in ControlParams.DeleteColumnsName)
                {
                    if (dgv.Columns.Contains(item)) dgv.Columns.Remove(item);
                }
            }
        }