Пример #1
0
        public LGPConstantSet Clone()
        {
            LGPConstantSet clone = new LGPConstantSet();

            clone.mWeightSum = mWeightSum;
            foreach (KeyValuePair <LGPRegister, double> point in mRegisters)
            {
                clone.mRegisters.Add(new KeyValuePair <LGPRegister, double>(point.Key.Clone(), point.Value));
            }
            return(clone);
        }
        protected virtual LGPConstantSet CreateConstantSet()
        {
            LGPConstantSet constant_set = new LGPConstantSet();
            int            reg_count    = mPop.ConstantRegisterCount;

            for (int i = 0; i < reg_count; ++i)
            {
                constant_set.AddConstant(mPop.FindConstantRegisterValueByIndex(i), mPop.FindConstantRegisterWeightByIndex(i));
            }

            return(constant_set);
        }
        public void Copy(LGPProgram rhs)
        {
            mSetup          = rhs.mSetup;
            mFitness        = rhs.mFitness;
            mObjectiveValue = rhs.mObjectiveValue;
            mIsFitnessValid = rhs.mIsFitnessValid;

            mRegisterSet = rhs.mRegisterSet.Clone();
            mOperatorSet = rhs.mOperatorSet.Clone();
            mConstantSet = rhs.mConstantSet.Clone();

            mPop = rhs.mPop;

            for (int i = 0; i < rhs.mInstructions.Count; ++i)
            {
                mInstructions.Add(rhs.mInstructions[i].Clone());
                mInstructions[i].Program = this;
            }
        }
 public void Setup()
 {
     mRegisterSet = CreateRegisterSet();
     mConstantSet = CreateConstantSet();
     mSetup       = true;
 }