Пример #1
0
        public PenaltyVector ExecuteFunctions(Matrix x)
        {
            PenaltyVector res = new PenaltyVector(functions.Length);

            OutOfDefinitionRangeException ex = new OutOfDefinitionRangeException();

            for (int i = 0; i < functions.Length; i++)
            {
                try
                {
                    res[i] = functions[i](x);
                    if (res[i] < 0)
                    {
                        res[i] = 0;
                    }
                }
                catch (Exception e)
                {
                    res[i] = Double.NaN;
                    ex.AddFunction(i);
                }
            }

            return(res);
        }
Пример #2
0
        public static PenaltyVector operator *(PenaltyVector b, double a)
        {
            PenaltyVector c = new PenaltyVector(b.Length);

            for (int i = 0; i < b.Length; i++)
            {
                c[i] = a * b[i];
            }

            return(c);
        }