Exemplo n.º 1
0
        /// <summary>
        /// Sets the input and output dimensions
        /// </summary>
        /// <param name="inputDimension"></param>
        /// <param name="outputDimension"></param>
        protected bool TrySetDimensions(int inputDimension, int outputDimension)
        {
            //if input is fixed
            if (inputDimension != 0)
            {
                if (HasParent)
                {
                    if (!parent.TryMatchOutputDimension(inputDimension))
                    {
                        return(false);
                    }
                }

                InputIsFixedSize = true;
            }
            else
            {
                InputIsFixedSize = false;
            }

            //if output is fixed
            if (outputDimension != 0)
            {
                OutputIsFixedSize = true;
            }
            else
            {
                OutputIsFixedSize = false;
            }

            InputDimension  = inputDimension;
            OutputDimension = outputDimension;

            return(true);
        }
Exemplo n.º 2
0
        public bool TryAddParent(Boa_Algorithm parentToAdd, out string errorDescription)
        {
            if (parentToAdd == null)
            {
                errorDescription = "Parent is null";
                return(false);
            }

            if (!parentToAdd.IsValid)
            {
                errorDescription = "Parent " + parentToAdd.IsValidWhyNot;
                return(false);
            }

            if (!parentToAdd.CanBeParentOf(this))
            {
                errorDescription = "Algorithms are of incompatible size";
                return(false);
            }

            //if parent's output is not fixed
            if (!parentToAdd.OutputIsFixedSize)
            {
                if (!parentToAdd.TryMatchOutputDimension(InputDimension))
                {
                    errorDescription = "Parenting would result in an input size of 0 or less";
                    return(false);
                }
            }

            //if this input is not fixed
            else if (!InputIsFixedSize)
            {
                //if this algorithm's size is relative but the parent's size is fixed
                if (!TryMatchInputDimension(parentToAdd.OutputDimension))
                {
                    errorDescription = "Parenting would result in an output size of 0 or less";
                    return(false);
                }
            }

            parent           = parentToAdd;
            HasParent        = true;
            errorDescription = "Algorithm has been successfully parented";

            return(true);
        }