Example #1
0
        /// <summary>
        /// Sets the individual as illegal and the state as <see cref="IndividualState.Evaluated"/>.
        /// </summary>
        public void SetIllegal()
        {
            if (State != IndividualState.Evaluating)
            {
                throw new InvalidOperationException("Individual is not evaluating!");
            }

            Legal = false;
            State = IndividualState.Evaluated;
        }
Example #2
0
        /// <summary>
        /// Assigns Fitness value.
        /// </summary>
        /// <remarks>Can be performed more than once.</remarks>
        /// <param name="fitness">
        /// The fitness value which has been calculated by the <see cref="Optimiser"/>.
        /// <seealso cref="PopOptBox.Base.FitnessCalculation.IFitnessCalculator"/>
        /// </param>
        /// <exception cref="InvalidOperationException">Thrown when Individual is not evaluated. <seealso cref="SetSolution"/>.</exception>
        public void SetFitness(double fitness)
        {
            if (State != IndividualState.Evaluated && State != IndividualState.FitnessAssessed)
            {
                throw new InvalidOperationException("Individual is not evaluated!");
            }

            Fitness = fitness;

            State = IndividualState.FitnessAssessed;
        }
Example #3
0
 /// <summary>
 /// Call when sending for evaluation.
 /// </summary>
 /// <remarks>Managed automatically by <see cref="Model{TReality}"/>.</remarks>
 /// <exception cref="InvalidOperationException">Individual is not new.</exception>
 internal void SendForEvaluation()
 {
     if (State == IndividualState.New)
     {
         State = IndividualState.Evaluating;
     }
     else
     {
         throw new InvalidOperationException("Individual is not new!");
     }
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     levelManager = FindObjectOfType <LevelManager>();
     for (int i = 0; i < states.Length; i++)
     {
         // load the states into the dictionary
         stateDictionary.Add(states[i].StateName, states[i]);
     }
     currentState = stateDictionary[startingState];
     currentState.Enter();
 }
Example #5
0
        /// <summary>
        /// Assigns Solution Vector based on given Property names and sets State to <see cref="IndividualState.Evaluated"/>.
        /// </summary>
        /// <param name="keyNames">Names of property keys to set as solution vector.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when any property name does not exist.</exception>
        public void SetSolution(params string[] keyNames)
        {
            if (State != IndividualState.Evaluating)
            {
                throw new InvalidOperationException("Individual is not evaluating!");
            }

            SolutionVector = keyNames.Select(GetProperty <double>).ToArray();

            Legal = true;
            State = IndividualState.Evaluated;
        }
Example #6
0
 public void Transition(string stateName)
 {
     currentState = stateDictionary[stateName];
     currentState.Enter();
 }
Example #7
0
 // Move to another state
 public void Transition(int stateID)
 {
     currentState = states[stateID];
     currentState.Enter();
 }