Пример #1
0
        /// <summary>
        ///   Initialises a LogisticRegressionGenerator object
        /// </summary>
        public LogisticRegressionGenerator()
        {
            Lambda             = 1;
            MaxIterations      = 500;
            PolynomialFeatures = 0;
            LearningRate       = 0.3;
            LogisticFunction   = new Logistic();

            NormalizeFeatures = true;
        }
Пример #2
0
        private Layer ConvertLogistic(tflite.Operator op)
        {
            var inputs = op.GetInputsArray();
            var input  = _graph.Tensors(inputs[0]).Value;

            var layer = new Logistic(input.GetShapeArray().ToNCHW());

            _inputs.Add(layer.Input, inputs[0]);
            _outputs.Add(op.Outputs(0), layer.Output);
            return(layer);
        }
Пример #3
0
        public IHttpActionResult GetLogistic(string id)
        {
            Logistic logistic = db.Logistics.Find(id);

            if (logistic == null)
            {
                return(NotFound());
            }

            return(Ok(logistic));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Verlengkabels,Voltage110,Comments")] Logistic logistic)
        {
            if (ModelState.IsValid)
            {
                _context.Add(logistic);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(logistic));
        }
Пример #5
0
        string type = String.Empty; // 对象类型
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            OtherPayBill ent = null;

            switch (RequestActionString)
            {
            case "update":
                ent = OtherPayBill.Find(id);
                string nowPayAmount = RequestData.Get <string>("NowPayAmount");
                if (!string.IsNullOrEmpty(nowPayAmount))
                {
                    ent.AcctualPayAmount = (ent.AcctualPayAmount.HasValue ? ent.AcctualPayAmount : 0) + Convert.ToDecimal(nowPayAmount);
                    if (ent.AcctualPayAmount == ent.ShouldPayAmount)
                    {
                        ent.PayState    = "已付款";
                        ent.PayTime     = System.DateTime.Now;
                        ent.PayUserId   = UserInfo.UserID;
                        ent.PayUserName = UserInfo.Name;
                    }
                    ent.DoUpdate();
                }
                if (ent.PayType == "物流付款" && ent.PayState == "已付款")
                {
                    string[] temparray = ent.InterfaceArray.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < temparray.Length; i++)
                    {
                        Logistic lEnt = Logistic.Find(temparray[i]);
                        lEnt.PayState = "已付款";
                        lEnt.DoUpdate();
                    }
                }
                break;

            default:
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = OtherPayBill.Find(id);
                    SetFormData(ent);
                    PageState.Add("PayType", ent.PayType);
                    if (ent.PayType == "物流付款")
                    {
                        string[] array = ent.InterfaceArray.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        PageState.Add("DataList", Logistic.FindAllByPrimaryKeys(array));
                    }
                }
            }
        }
Пример #6
0
        public async Task <IHttpActionResult> GetLogistic(int id)
        {
            Logistic logistic = await db.Logistics.FindAsync(id);

            if (logistic == null)
            {
                return(NotFound());
            }
            await db.Entry(logistic).Collection(log => log.LogisticInfos).LoadAsync();

            return(Ok(logistic));
        }
Пример #7
0
        void ITrainer.Fit(Func <bool> HasCtrlBreak)
        {
            for (var k = 0; k < POSITIVES; k++)
            {
                var Yes = GetRandomSample();
                var y   = Model[Yes.Item2];
                if (y != null)
                {
                    const float POSITIVE = 1.0f;
                    Logistic.BinaryLogistic(y.GetVector(), Yes.Item1, POSITIVE, lr, null);
                    for (var h = 0; h < NEGATIVES; h++)
                    {
                        var No = GetRandomSample();
                        while (No != null && string.Equals(No.Item2, Yes.Item2))
                        {
                            No = GetRandomSample();
                        }
                        if (No != null)
                        {
                            const float NEGATIVE = 0.0f;
                            Logistic.BinaryLogistic(y.GetVector(), No.Item1, NEGATIVE, lr, null);
                        }
                    }
                }
            }
            double pct = 0,
                   cc  = 0d;

            foreach (var y in Model)
            {
                foreach (var s in Samples)
                {
                    var σ = Logistic.BinaryLogistic(y, s.Item1);
                    if (y.Id.Equals(s.Item2))
                    {
                        if (σ >= 0.5)
                        {
                            pct++;
                        }
                    }
                    else
                    {
                        if (σ < 0.5)
                        {
                            pct++;
                        }
                    }
                    cc++;
                }
            }
            _accuracy = Math.Round((pct / cc) * 100);
        }
Пример #8
0
 public IActionResult Put(int id, [FromBody] Logistic logistic)
 {
     if (logistic != null)
     {
         using (var scope = new TransactionScope())
         {
             _logisticRepository.UpdateLogistic(logistic);
             scope.Complete();
             return(new OkResult());
         }
     }
     return(new NoContentResult());
 }
Пример #9
0
        public void EditLogistic(string name, string description, decimal amount, int quantity, int programId, int logisticId, int eventId)
        {
            // FUNCTION: Edit a new logistic
            // PRE-CONDITIONS:
            // POST-CONDITIONS:
            Logistic logistic = server.GetEvent(eventId).EditLogistic(logisticId);

            logistic.name        = name;
            logistic.description = description;
            logistic.amount      = amount;
            logistic.quantity    = quantity;
            logistic.programId   = programId;
        }
Пример #10
0
        public IHttpActionResult DeleteLogistic(string id)
        {
            Logistic logistic = db.Logistics.Find(id);

            if (logistic == null)
            {
                return(NotFound());
            }

            db.Logistics.Remove(logistic);
            db.SaveChanges();

            return(Ok(logistic));
        }
Пример #11
0
        //Редактиране на данни
        public bool Update(Logistic logistic)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                String sql = "UPDATE table_logistic SET employee=@employee, first_name_employee=@first_name_employee, last_name_employee=@last_name_employee, address=@address, contact=@contact, date=@date, description=@description, price=@price, added_date=@added_date, added_by=@added_by, added_by_name=@added_by_name WHERE id=@id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@employee", logistic.Empleyee);
                cmd.Parameters.AddWithValue("@first_name_employee", logistic.FirstNameEmployee);
                cmd.Parameters.AddWithValue("@last_name_employee", logistic.LastNameEmployee);
                cmd.Parameters.AddWithValue("@address", logistic.Address);
                cmd.Parameters.AddWithValue("@contact", logistic.Contact);
                cmd.Parameters.AddWithValue("@date", logistic.Date);
                cmd.Parameters.AddWithValue("@description", logistic.Description);
                cmd.Parameters.AddWithValue("@price", logistic.Price);
                cmd.Parameters.AddWithValue("@added_date", logistic.AddedDate);
                cmd.Parameters.AddWithValue("@added_by", logistic.AddedBy);
                cmd.Parameters.AddWithValue("@added_by_name", logistic.AddedByName);
                cmd.Parameters.AddWithValue("@id", logistic.Id);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
Пример #12
0
    public static void logistic_cdf_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LOGISTIC_CDF_VALUES_TEST tests LOGISTIC_CDF_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    13 June 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double beta = 0;
        double fx   = 0;
        double mu   = 0;
        int    n_data;
        double x = 0;

        Console.WriteLine("");
        Console.WriteLine("LOGISTIC_CDF_VALUES_TEST:");
        Console.WriteLine("  LOGISTIC_CDF_VALUES returns values of ");
        Console.WriteLine("  the Logistic Cumulative Density Function.");
        Console.WriteLine("");
        Console.WriteLine("     Mu      Beta         X   CDF(X)");
        Console.WriteLine("");
        n_data = 0;
        for (;;)
        {
            Logistic.logistic_cdf_values(ref n_data, ref mu, ref beta, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + mu.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + beta.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + fx.ToString("0.################").PadLeft(24) + "");
        }
    }
Пример #13
0
        //Добавяне
        public bool Insert(Logistic logistic)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                String sql = "INSERT INTO table_logistic_archive (employee, first_name_employee, last_name_employee, address, contact, date, description, price, added_date, added_by, added_by_name) VALUES (@employee, @first_name_employee, @last_name_employee, @address, @contact, @date, @description, @price, @added_date, @added_by, @added_by_name)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@employee", logistic.Empleyee);
                cmd.Parameters.AddWithValue("@first_name_employee", logistic.FirstNameEmployee);
                cmd.Parameters.AddWithValue("@last_name_employee", logistic.LastNameEmployee);
                cmd.Parameters.AddWithValue("@address", logistic.Address);
                cmd.Parameters.AddWithValue("@contact", logistic.Contact);
                cmd.Parameters.AddWithValue("@date", logistic.Date);
                cmd.Parameters.AddWithValue("@description", logistic.Description);
                cmd.Parameters.AddWithValue("@price", logistic.Price);
                cmd.Parameters.AddWithValue("@added_date", logistic.AddedDate);
                cmd.Parameters.AddWithValue("@added_by", logistic.AddedBy);
                cmd.Parameters.AddWithValue("@added_by_name", logistic.AddedByName);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
Пример #14
0
        public int AddLogistic(string name, string description, decimal amount, int quantity, int programId, int eventId)
        {
            // FUNCTION: Add a new logistic
            // PRE-CONDITIONS:
            // POST-CONDITIONS:
            Logistic logistic = new Logistic();

            logistic.name        = name;
            logistic.description = description;
            logistic.amount      = amount;
            logistic.quantity    = quantity;
            logistic.programId   = programId;
            server.GetEvent(eventId).AddLogistic(logistic);

            return(logistic.logisticId);
        }
        public void SingleInput_WeightOne()
        {
            var connList = new List <WeightedDirectedConnection <double> >();

            connList.Add(new WeightedDirectedConnection <double>(0, 1, 1.0));

            // Create graph.
            var digraph = WeightedDirectedGraphAcyclicBuilder <double> .Create(connList, 1, 1);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetAcyclic(digraph, actFn.Fn);

            SingleInput_WeightOne_Inner(net, actFn);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNet.Double.Vectorized.NeuralNetAcyclic(digraph, actFn.Fn);

            SingleInput_WeightOne_Inner(vnet, actFn);
        }
Пример #16
0
        public async Task <IHttpActionResult> AddLogisticInfo(int LogisticID, [FromBody] LogisticInfo logisticInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Logistic logistic = await db.Logistics.FindAsync(LogisticID);

            if (logistic == null)
            {
                return(NotFound());
            }
            logisticInfo.LogisticID = logistic.LogisticID;
            db.LogisticInfoes.Add(logisticInfo);
            await db.SaveChangesAsync();

            var httpResp = Request.CreateResponse(HttpStatusCode.NoContent);

            return(ResponseMessage(httpResp));
        }
Пример #17
0
        string type = String.Empty; // 对象类型
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            OtherPayBill ent = null;

            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = OtherPayBill.Find(id);
                    PageState.Add("PayType", ent.PayType);
                    SetFormData(ent);
                    if (ent.PayType == "物流付款")
                    {
                        string[] array = ent.InterfaceArray.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        PageState.Add("DataList", Logistic.FindAllByPrimaryKeys(array));
                    }
                }
            }
        }
Пример #18
0
        /// <summary>
        /// 查询
        /// </summary>
        private void DoSelect()
        {
            if (!SearchCriterion.Orders.Exists(en => en.PropertyName == "CreateTime"))
            {
                SearchCriterion.Orders.Add(new OrderCriterionItem("CreateTime", false));
            }

            string paystate = RequestData.Get <string>("paystate");

            if (paystate == "1")
            {
                SearchCriterion.AddSearch("PayState", "1");
                ents = Logistic.FindAll(SearchCriterion);
            }
            else
            {
                ents = Logistic.FindAll(SearchCriterion, Expression.Sql(" isnull(PayState,0) <> '1' "));
            }

            this.PageState.Add("LogisticList", ents);
        }
        public void SingleInput_WeightZero()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 1, 0.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphBuilder <double> .Create(connList, 1, 1);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetCyclic(digraph, actFn.Fn, 2);

            SingleInput_WeightZero_Inner(net);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNets.Double.Vectorized.NeuralNetCyclic(digraph, actFn.Fn, 2);

            SingleInput_WeightZero_Inner(vnet);
        }
        public void TwoInputs_WeightHalf()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 2, 0.5),
                new WeightedDirectedConnection <double>(1, 2, 0.5)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphAcyclicBuilder <double> .Create(connList, 2, 1);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetAcyclic(digraph, actFn.Fn);

            TwoInputs_WeightHalf_Inner(net, actFn);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNet.Double.Vectorized.NeuralNetAcyclic(digraph, actFn.Fn);

            TwoInputs_WeightHalf_Inner(vnet, actFn);
        }
Пример #21
0
        /// <summary>
        /// Compute the error gradient of the given Theta parameter for the training and label sets
        /// </summary>
        /// <param name="theta">Learning Theta parameters</param>
        /// <param name="X">Training set</param>
        /// <param name="y">Training labels</param>
        /// <param name="lambda">Regularisation constant</param>
        /// <param name="regularizer">Regularization term function.</param>
        /// <returns></returns>
        public Vector ComputeGradient(Vector theta, Matrix X, Vector y, double lambda, IRegularizer regularizer)
        {
            int m = X.Rows;
            Vector gradient = Vector.Zeros(theta.Length);

            Vector s = (X * theta).ToVector();

            IFunction function = new Logistic();
            s = s.Each(v => function.Compute(v));

            for (int i = 0; i < theta.Length; i++)
            {
                gradient[i] = (1.0 / m) * ((s - y) * X[i, VectorType.Col]).Sum();
            }

            if (lambda != 0)
            {
                gradient = regularizer.Regularize(theta, gradient, m, lambda);
            }

            return gradient;
        }
Пример #22
0
        /// <summary>
        /// Compute the error cost of the given Theta parameter for the training and label sets
        /// </summary>
        /// <param name="theta">Learning Theta parameters</param>
        /// <param name="X">Training set</param>
        /// <param name="y">Training labels</param>
        /// <param name="lambda">Regularization constant</param>
        /// <param name="regularizer">Regularization term function.</param>
        /// <returns></returns>
        public double ComputeCost(Vector theta, Matrix X, Vector y, double lambda, IRegularizer regularizer)
        {
            int m = X.Rows;

            double j = 0.0;

            Vector s = (X * theta).ToVector();

            IFunction function = new Logistic();
            s = s.Each(v => function.Compute(v));

            Vector slog = s.Copy().Each(v => System.Math.Log(System.Math.Abs(1.0 - v)));

            j = (-1.0 / m) * ( (y.Dot(s.Log())) + (-1.0 * ((1.0 - y).Dot(slog))) );

            if (lambda != 0)
            {
                j = regularizer.Regularize(j, theta, m, lambda);
            }

            return j;
        }
        public void CyclicOutput()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 1, 1.0),
                new WeightedDirectedConnection <double>(1, 1, 1.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphBuilder <double> .Create(connList, 1, 1);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetCyclic(digraph, actFn.Fn, 1);

            CyclicOutput_Inner(net, actFn);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNet.Double.Vectorized.NeuralNetCyclic(digraph, actFn.Fn, 1);

            CyclicOutput_Inner(vnet, actFn);
        }
Пример #24
0
        //Изтриване на данни
        public bool Delete(Logistic logistic)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                String sql = "DELETE FROM table_logistic WHERE id=@id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@id", logistic.Id);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
        public void SingleInput_WeightOne()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 1, 1.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphBuilder <double> .Create(connList, 1, 1);

            // Create neural net
            var actFn = new Logistic();
            var net   = new CyclicNeuralNet(digraph, actFn.Fn, 1, false);

            // Activate and test.
            net.InputVector[0] = 0.0;
            for (int i = 0; i < 10; i++)
            {
                net.Activate();
                Assert.AreEqual(0.5, net.OutputVector[0]);
            }

            // Activate and test.
            net.InputVector[0] = 1.0;
            for (int i = 0; i < 10; i++)
            {
                net.Activate();
                Assert.AreEqual(actFn.Fn(1), net.OutputVector[0]);
            }

            // Activate and test.
            net.InputVector[0] = 10.0;
            for (int i = 0; i < 10; i++)
            {
                net.Activate();
                Assert.AreEqual(actFn.Fn(10), net.OutputVector[0]);
            }
        }
Пример #26
0
        public void HiddenNode()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 3, 0.5),
                new WeightedDirectedConnection <double>(1, 3, 0.5),
                new WeightedDirectedConnection <double>(3, 2, 2.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphAcyclicBuilder <double> .Create(connList, 2, 1);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetAcyclic(digraph, actFn.Fn);

            HiddenNode_Inner(net, actFn);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNets.Double.Vectorized.NeuralNetAcyclic(digraph, actFn.Fn);

            HiddenNode_Inner(vnet, actFn);
        }
        public void MultipleInputsOutputs()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 5, 1.0),
                new WeightedDirectedConnection <double>(1, 3, 1.0),
                new WeightedDirectedConnection <double>(2, 4, 1.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphAcyclicBuilder <double> .Create(connList, 3, 3);

            // Create neural net and run tests.
            var actFn = new Logistic();
            var net   = new NeuralNetAcyclic(digraph, actFn.Fn);

            MultipleInputsOutputs_Inner(net, actFn);

            // Create vectorized neural net and run tests.
            var vnet = new NeuralNet.Double.Vectorized.NeuralNetAcyclic(digraph, actFn.Fn);

            MultipleInputsOutputs_Inner(vnet, actFn);
        }
Пример #28
0
        /// <summary>
        ///     Compute the error gradient of the given Theta parameter for the training and label sets
        /// </summary>
        /// <param name="theta">Learning Theta parameters</param>
        /// <param name="X">Training set</param>
        /// <param name="y">Training labels</param>
        /// <param name="lambda">Regularisation constant</param>
        /// <param name="regularizer">Regularization term function.</param>
        /// <returns></returns>
        public Vector ComputeGradient(Vector theta, Matrix X, Vector y, double lambda, IRegularizer regularizer)
        {
            var m        = X.Rows;
            var gradient = Vector.Zeros(theta.Length);

            var s = (X * theta).ToVector();

            IFunction function = new Logistic();

            s = s.Each(v => function.Compute(v));

            for (var i = 0; i < theta.Length; i++)
            {
                gradient[i] = (1.0 / m) * ((s - y) * X[i, VectorType.Col]).Sum();
            }

            if (lambda != 0)
            {
                gradient = regularizer.Regularize(theta, gradient, m, lambda);
            }

            return(gradient);
        }
Пример #29
0
        /// <summary>
        ///     Compute the error cost of the given Theta parameter for the training and label sets
        /// </summary>
        /// <param name="theta">Learning Theta parameters</param>
        /// <param name="X">Training set</param>
        /// <param name="y">Training labels</param>
        /// <param name="lambda">Regularization constant</param>
        /// <param name="regularizer">Regularization term function.</param>
        /// <returns></returns>
        public double ComputeCost(Vector theta, Matrix X, Vector y, double lambda, IRegularizer regularizer)
        {
            var m = X.Rows;

            var j = 0.0;

            var s = (X * theta).ToVector();

            IFunction function = new Logistic();

            s = s.Each(v => function.Compute(v));

            var slog = s.Copy().Each(v => Math.Log(Math.Abs(1.0 - v)));

            j = (-1.0 / m) * (y.Dot(s.Log()) + (-1.0 * (1.0 - y).Dot(slog)));

            if (lambda != 0)
            {
                j = regularizer.Regularize(j, theta, m, lambda);
            }

            return(j);
        }
Пример #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (RequestActionString == "batchdelete")
            {
                DoBatchDelete();
            }
            else if (RequestActionString == "duiying")
            {
                string did = RequestData.Get <string>("DId");
                string lid = RequestData.Get <string>("LId");

                Logistic ent = Logistic.TryFind(lid);
                if (ent != null)
                {
                    ent.DeliveryId = did;
                    ent.DoUpdate();
                }
            }
            else
            {
                DoSelect();
            }
        }
        public void ComplexCyclic()
        {
            var connList = new List <WeightedDirectedConnection <double> >
            {
                new WeightedDirectedConnection <double>(0, 1, -2.0),
                new WeightedDirectedConnection <double>(0, 2, 1.0),
                new WeightedDirectedConnection <double>(1, 2, 1.0),
                new WeightedDirectedConnection <double>(2, 1, 1.0)
            };

            // Create graph.
            var digraph = WeightedDirectedGraphBuilder <double> .Create(connList, 1, 1);

            // Create neural net
            var actFn = new Logistic();
            var net   = new CyclicNeuralNet(digraph, actFn.Fn, 1, false);

            // Simulate network in C# and compare calculated outputs with actual network outputs.
            double[] preArr  = new double[3];
            double[] postArr = new double[3];

            postArr[0]         = 3.0;
            net.InputVector[0] = 3.0;

            for (int i = 0; i < 10; i++)
            {
                preArr[1] = postArr[0] * -2.0 + postArr[2];
                preArr[2] = postArr[0] + postArr[1];

                postArr[1] = actFn.Fn(preArr[1]);
                postArr[2] = actFn.Fn(preArr[2]);

                net.Activate();

                Assert.AreEqual(postArr[1], net.OutputVector[0]);
            }
        }
Пример #32
0
        string id = String.Empty;   // 对象id
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get <string>("id");
            Logistic ent = Logistic.Find(id);

            SetFormData(ent);
            DataTable  tbl = new DataTable();
            DataColumn col = new DataColumn("Code");

            col.DataType = typeof(string);
            tbl.Columns.Add(col);
            col          = new DataColumn("Name");
            col.DataType = typeof(string);
            tbl.Columns.Add(col);
            col          = new DataColumn("Unit");
            col.DataType = typeof(string);
            tbl.Columns.Add(col);
            col          = new DataColumn("OutCount");
            col.DataType = typeof(string);
            tbl.Columns.Add(col);
            col          = new DataColumn("Remark");
            col.DataType = typeof(string);
            tbl.Columns.Add(col);
            JArray jsonarray = JsonHelper.GetObject <JArray>(ent.Child);

            foreach (JObject json in jsonarray)
            {
                DataRow dr = tbl.NewRow();
                dr["Code"]     = json.Value <string>("Code");
                dr["Name"]     = json.Value <string>("Name");
                dr["OutCount"] = json.Value <string>("OutCount");
                dr["Unit"]     = json.Value <string>("Unit");
                dr["Remark"]   = json.Value <string>("Remark");
                tbl.Rows.Add(dr);
            }
            PageState.Add("DataList", tbl);
        }
Пример #33
0
 /// <summary>
 /// Initializes a new LogisticCostFunction with the default sigmoid logistic function.
 /// </summary>
 public LogisticCostFunction()
 {
     if (LogisticFunction == null)
         LogisticFunction = new Logistic();
 }