Exemplo n.º 1
0
        public virtual void Setup(IEvolutionState state, IParameter paramBase)
        {
            var constraintName = state.Parameters.GetString(paramBase.Push(P_CONSTRAINTS), DefaultBase.Push(P_CONSTRAINTS));

            if (constraintName == null)
            {
                state.Output.Fatal("No RuleConstraints name given", paramBase.Push(P_CONSTRAINTS), DefaultBase.Push(P_CONSTRAINTS));
            }

            ConstraintCount = RuleConstraints.ConstraintsFor(constraintName, state).ConstraintCount;
            state.Output.ExitIfErrors();
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets up all the RuleConstraints, loading them from the parameter
        /// file.  This must be called before anything is called which refers
        /// to a type by name.
        /// </summary>
        public virtual void SetupConstraints(IEvolutionState state, IParameter paramBase)
        {
            state.Output.Message("Processing Rule Constraints");

            // How many RuleConstraints do we have?
            var x = state.Parameters.GetInt(paramBase.Push(P_SIZE), null, 1);

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

            // Load our constraints
            for (var y = 0; y < x; y++)
            {
                RuleConstraints c;
                // Figure the constraints class
                if (state.Parameters.ParameterExists(paramBase.Push("" + y), null))
                {
                    c = (RuleConstraints)(state.Parameters.GetInstanceForParameterEq(paramBase.Push("" + y), null, typeof(RuleConstraints)));
                }
                else
                {
                    state.Output.Message("No Rule Constraints specified, assuming the default class: ec.rule.RuleConstraints for " + paramBase.Push("" + y));
                    c = new RuleConstraints();
                }
                c.Setup(state, paramBase.Push("" + y));
            }

            // set our constraints array up
            var e = RuleConstraintRepository.Values.GetEnumerator();

            while (e.MoveNext())
            {
                var c = (RuleConstraints)(e.Current);
                c.ConstraintCount = NumRuleConstraints;
                RuleConstraints[NumRuleConstraints] = c;
                NumRuleConstraints++;
            }
        }