示例#1
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
        {
            context.Logger.Log("Starting Minimum Get call");

            using (AwsFactory factory = new AwsFactory(context.Logger))
            {
                string userId    = request.PathParameters["userId"];
                string firstName = request.PathParameters["firstName"];

                context.Logger.LogLine($"userId=\"{userId}\"");
                context.Logger.LogLine($"firstName=\"{firstName}\"");

                using (GetMinimum getMinimum = new GetMinimum(factory))
                {
                    string jsonResponse = getMinimum.Retrieve(userId, firstName);

                    context.Logger.LogLine($"Response: {jsonResponse}");
                    APIGatewayProxyResponse response = new APIGatewayProxyResponse()
                    {
                        Body       = jsonResponse,
                        StatusCode = 200
                    };

                    return(response);
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            if (!ParseOptions())
            {
                Console.WriteLine("Error parsing options!");
                return;
            }


            GetMinimum.Execute();

            //}
            //Matrix<double> d = DenseMatrix.OfArray(new Double[,] {
            //    {-1},
            //    {-1},
            //    {1},
            //    {1}
            //});

            //Console.WriteLine (String.Concat(">>>> ",d.Transpose().Multiply(Functions.d2f(0,0,0,0)).Multiply(d)));

            //// Iterando sobre o vetor inicial
            //for (int i = 0; i < _x0.Length; i++)
            //{
            //    Console.WriteLine (_x0[i].ToString("0.00"));
            //}

            //// Calculando o passo usando Armijo
            //double t = Armijo.Execute( DenseMatrix.OfArray(new Double[,] { { 1 }, { 0 } }),
            //                           DenseMatrix.OfArray(new Double[,] { { 3 }, { 1 } })
            //                          );


            Matrix <double> x = DenseMatrix.OfArray(new Double[, ] {
                { _x0[0] },
                { _x0[1] },
                { _x0[2] },
                { _x0[3] }
            });


            using (StreamWriter sw = new StreamWriter(@"C:\Users\yagom\Desktop\trab-otim.csv", true))
            {
                sw.WriteLine(String.Format("{0};{1};{2};{3};{4};{5}", "X0", "Iter", "Busca", "Chamada Busca", "Ponto Mínimo", "Valor da função no ponto mínimo"));
                sw.Flush();
            }

            for (double k = 0.1; k < 1.0; k = k + 0.1)
            {
                ExteriorPenalty.Execute(x.Add(-k), 10, 3.0, false);
                ExteriorPenalty.Execute(x.Add(-k), 10, 3.0, true);
            }

            Console.ReadKey();
        }