Пример #1
0
        public virtual void SetupRuleSetConstraints(IEvolutionState state, IParameter paramBase)
        {
            state.Output.Message("Processing Ruleset Constraints");
            // How many RuleSetConstraints do we have?
            var x = state.Parameters.GetInt(paramBase.Push(P_SIZE), null, 1);

            if (x <= 0)
            {
                state.Output.Fatal("The number of RuleSetConstraints must be at least 1.", paramBase.Push(P_SIZE));
            }

            // Load our RuleSetConstraints
            for (var y = 0; y < x; y++)
            {
                RuleSetConstraints c;
                // Figure the RuleSetConstraints class
                if (state.Parameters.ParameterExists(paramBase.Push("" + y), null))
                {
                    c = (RuleSetConstraints)(state.Parameters.GetInstanceForParameterEq(paramBase.Push("" + y), null, typeof(RuleSetConstraints)));
                }
                else
                {
                    state.Output.Message("No RuleSetConstraints specified, assuming default class: ec.gp.RuleSetConstraints for " + paramBase.Push("" + y));
                    c = new RuleSetConstraints();
                }
                c.Setup(state, paramBase.Push("" + y));
            }
            // set our constraints array up
            foreach (RuleSetConstraints c in RuleSetConstraintRepository)
            {
                c.ConstraintCount = NumRuleSetConstraints;
                RuleSetConstraints[NumRuleSetConstraints] = c;
                NumRuleSetConstraints++;
            }
        }
Пример #2
0
        public virtual void Setup(IEvolutionState state, IParameter paramBase)
        {
            var constraintName = state.Parameters.GetString(paramBase.Push(P_CONSTRAINTS), DefaultBase.Push(P_CONSTRAINTS));

            if (String.IsNullOrEmpty(constraintName))
            {
                state.Output.Fatal("No RuleSetConstraints name given", paramBase.Push(P_CONSTRAINTS), DefaultBase.Push(P_CONSTRAINTS));
            }

            ConstraintCount = RuleSetConstraints.ConstraintsFor(constraintName, state).ConstraintCount;
            state.Output.ExitIfErrors();
        }
Пример #3
0
        /// <summary>
        /// Sets up the RuleConstraints and RuleSetConstraints cliques.
        /// </summary>
        public override void Setup(IEvolutionState state, IParameter paramBase)
        {
            base.Setup(state, paramBase);

            RuleConstraintRepository = Hashtable.Synchronized(new Hashtable());
            RuleConstraints          = new RuleConstraints[SIZE_OF_BYTE];
            NumRuleConstraints       = 0;

            RuleSetConstraintRepository = Hashtable.Synchronized(new Hashtable());
            RuleSetConstraints          = new RuleSetConstraints[SIZE_OF_BYTE];
            NumRuleSetConstraints       = 0;

            // Now let's load our constraints and function sets also.
            // This is done in a very specific order, don't change it or things
            // will break.
            SetupConstraints(state, RuleDefaults.ParamBase.Push(P_RULECONSTRAINTS));
            SetupRuleSetConstraints(state, RuleDefaults.ParamBase.Push(P_RULESETCONSTRAINTS));
        }