Example #1
0
 public List<Item> Randomize()
 {
     List<Item> L1, L2 = null;
     L1 = Items.Where(g => g.ItemType.Equals(ItemTypeEnum.Pretest)).Take(2).ToList<Item>();
     L2 = Items.Where(p => !L1.Any(p2 => p2.ItemId == p.ItemId)).ToList<Item>();
     return L1.Concat(L2).ToList();
 }        
Example #2
0
 public void Do_purge()
 {
     if (REG.usedSpace > 0)
     {
         REG.Dump_line();
     }
     else if (L1.usedSpace > 0)
     {
         Factory.INSTANCE.L3.Await_purged_data();
         L1.Dump_first_line_with_data();
     }
     else if (L2.usedSpace > 0)
     {
         Factory.INSTANCE.L3.Await_purged_data();
         L2.Dump_first_line_with_data();
         if (L2.usedSpace == 0)
         {
             // purge complete
             // reset all workshops - start searching fresh for parts
             foreach (var _WORKSHOP in Factory.INSTANCE.workshops)
             {
                 _WORKSHOP.Clear_all_requests_then_idle();
             }
         }
     }
     if (REG.currentState == StorageState.IDLE &&
         L1.currentState == StorageState.IDLE &&
         L2.currentState == StorageState.IDLE
         )
     {
         Cancel_purge();
     }
 }
        public SignUpEmployee(bool a = false)
        {
            Admin         = a;
            controllerObj = new Controller();
            InitializeComponent();

            if (!Admin)
            {
                foreach (Control c in Controls)
                {
                    c.Hide();
                }
                title.Show();
                L1.Show();
                button_Back.Show();
                Verify.Show();
                Access.Show();
            }
            else
            {
                L1.Hide();
                Verify.Hide();
                Access.Hide();
                label2.Visible   = true;
                label3.Visible   = true;
                Current.Visible  = true;
                Complete.Visible = true;
            }
        }
Example #4
0
 public void Request_viable_parts(VehiclePart_CHASSIS _chassis)
 {
     foreach (KeyValuePair <VehiclePart_Config, int> _PAIR in currentTask.requiredParts)
     {
         VehiclePart_Config _PART = _PAIR.Key;
         int _QUANTITY            = _PAIR.Value;
         if (_PART.partType != Vehicle_PartType.CHASSIS)
         {
             if (currentTask.requiredParts.ContainsKey(_PAIR.Key))
             {
                 if (factoryMode == FactoryMode.OOP)
                 {
                     if (_chassis.partsFitted.ContainsKey(_PART))
                     {
                         if (_chassis.partsFitted[_PART] >= _QUANTITY)
                         {
                             continue;
                         }
                     }
                 }
                 L1.Request_part(new VehiclePartRequest(_PAIR.Key, REG));
                 REG.waitingForPartType = _chassis.partsNeeded[0].partConfig;
                 if (!purgingPartsToSharedStorage)
                 {
                     REG.Change_state(StorageState.WAITING);
                 }
                 return;
             }
         }
     }
 }
    static void Main(string[] args)
    {
        var tree = new List <List <List <string> > >
        {
            new List <List <string> >
            {
                new List <string> {
                    "a", "b"
                },
                new List <string> {
                    "c"
                }
            },
            new List <List <string> >
            {
                new List <string> {
                    "x", "y"
                }
            }
        };
        IEnumerable <Tuple <string, int> > result = tree.SelectMany((L1, i) => L1.SelectMany(L2 => L2.Select(k => Tuple.Create(k, i))));

        foreach (var si in result)
        {
            Console.WriteLine(si.Item1 + ' ' + si.Item2);
        }
    }
Example #6
0
        private void btn_Read_Click(object sender, EventArgs e)
        {
            string L1, L2, L3;

            dataset.Clear();
            dataset         = DALFunc.QueryTable("EquipTypeSlet");
            txtbox_Num.Text = dataset.Tables[0].Rows[3].ToString();

            L1 = dataset.Tables[0].Rows[4].ToString();
            string[] L1D = L1.Split(';');
            lbox_L1.Items.Clear();
            for (int i = 0; i < L1D.Count(); i++)
            {
                lbox_L1.Items.Add(L1D[i]);
            }

            L2 = dataset.Tables[0].Rows[5].ToString();
            string[] L2D = L2.Split(';');
            lbox_L2.Items.Clear();
            for (int i = 0; i < L2D.Count(); i++)
            {
                lbox_L2.Items.Add(L2D[i]);
            }

            L3 = dataset.Tables[0].Rows[6].ToString();
            string[] L3D = L3.Split(';');
            lbox_L3.Items.Clear();
            for (int i = 0; i < L3D.Count(); i++)
            {
                lbox_L3.Items.Add(L3D[i]);
            }
        }
        /// <summary>
        /// Gets Besselian elements values for specified Juluan Day.
        /// </summary>
        /// <param name="jd">Julian Day of interest</param>
        /// <returns></returns>
        internal InstantBesselianElements GetInstantBesselianElements(double jd)
        {
            //if (jd < From || jd > To)
            //    throw new ArgumentException($"Polynomial Besselian elements valid only for Julian Day in range [{From} ... {To}].", nameof(jd));

            // difference, with t0, in step units
            double t = (jd - JulianDay0) / Step;

            return(new InstantBesselianElements()
            {
                X = X.Select((x, n) => x * Pow(t, n)).Sum(),
                Y = Y.Select((y, n) => y * Pow(t, n)).Sum(),
                L1 = L1.Select((l1, n) => l1 * Pow(t, n)).Sum(),
                L2 = L2.Select((l2, n) => l2 * Pow(t, n)).Sum(),
                D = D.Select((d, n) => d * Pow(t, n)).Sum(),
                Mu = To360(Mu.Select((mu, n) => mu * Pow(t, n)).Sum()),
                F1 = F1.Select((f1, n) => f1 * Pow(t, n)).Sum(),
                F2 = F2.Select((f2, n) => f2 * Pow(t, n)).Sum(),
                dX = Derivative(X, t),
                dY = Derivative(Y, t),
                dL1 = Derivative(L1, t),
                dL2 = Derivative(L2, t),
                dD = Derivative(D, t),
                dMu = Derivative(Mu, t)
            });
        }
 public void Draw(ref Graphics g, float originX, float originY, float scale, float offsetX, float offsetY, float brushSize)
 {
     L1.Draw(ref g, originX, originY, scale, offsetX, offsetY, brushSize);
     L2.Draw(ref g, originX, originY, scale, offsetX, offsetY, brushSize);
     L3.Draw(ref g, originX, originY, scale, offsetX, offsetY, brushSize);
     L4.Draw(ref g, originX, originY, scale, offsetX, offsetY, brushSize);
 }
Example #9
0
    static void Main(string[] args)
    {
        var tree = new List <List <List <Foo> > >
        {
            new List <List <Foo> >
            {
                new List <Foo> {
                    new Foo("a"), new Foo("b")
                },
                new List <Foo> {
                    new Foo("c")
                }
            },
            new List <List <Foo> >
            {
                new List <Foo> {
                    new Foo("x"), new Foo("y")
                }
            }
        };
        IEnumerable <Tuple <Foo, int> > result = tree.SelectMany((L1, i) => L1.SelectMany(L2 => L2.Select(k => Tuple.Create(k, i))));

        foreach (var si in result)
        {
            Console.WriteLine(si.Item1.s + ' ' + si.Item2);
        }
    }
    public static void Main(string[] args)
    {
        C1 c1 = new C1();      // create instance of class that raises event
        L1 l1 = new L1();      // create instance of 1st class that handles event
        L2 l2 = new L2();      // create instande of 2nd class that handles event

        // no handlers are yet registered on the event
        try
        {
            c1.Raise();     // will crash and output exception as no handler set yet
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        c1.SafeRaise();     // safe, will print message

        l1.AddListener(c1); // add as listener
        c1.Raise();         // prints handled message

        l2.AddListener(c1); // add 2nd listener
        c1.Raise();         // both print handled message

        Console.ReadLine(); // stop console from closing
    }
        private void Verify_Click(object sender, EventArgs e)
        {
            string Pass = Convert.ToString(controllerObj.GetAccess("Company").Rows[0][0]);

            if (Access.Text != Pass)
            {
                MessageBox.Show("Incorrect Pass code.");
            }
            else
            {
                foreach (Control c in Controls)
                {
                    c.Show();
                }
                L1.Hide();
                button_Back.Hide();
                Verify.Hide();
                Access.Hide();
                label2.Visible   = false;
                label3.Visible   = false;
                label1.Visible   = false;
                label4.Visible   = false;
                Current.Visible  = false;
                Complete.Visible = false;
                Cost.Visible     = false;
                Rating.Visible   = false;
                Save.Visible     = false;
            }
        }
Example #12
0
        public Cost(CostSettings settings)
        {
            BatchCost = 0;

            switch (settings.RegularizationType)
            {
            case ERegularizationType.Invalid:
                throw new ArgumentException("Invalid Regularization Function Selected!");

            case ERegularizationType.None:
                RegularizationFunction = new None();
                break;

            case ERegularizationType.L1:
                RegularizationFunction = new L1((L1Settings)settings.RegularizationSettings);
                break;

            case ERegularizationType.L2:
                RegularizationFunction = new L2((L2Settings)settings.RegularizationSettings);
                break;

            default:
                throw new ArgumentException("Invalid Regularization Function Selected!");
            }
        }
        private async void button1_Click(object sender, EventArgs e)
        {
            L1 l1 = new L1();

            l1.Show();
            this.Hide();
        }
        public SignUpBank(bool a = false)
        {
            Admin = a;

            controllerObj = new Controller();
            InitializeComponent();
            if (!Admin)
            {
                foreach (Control c in Controls)
                {
                    c.Hide();
                }
                title.Show();
                L1.Show();
                button_Back.Show();
                Verify.Show();
                Access.Show();
            }
            else
            {
                L1.Hide();
                Verify.Hide();
                Access.Hide();
            }
        }
 /// <summary>
 /// Add a set of evaluation metrics to the set of observations.
 /// </summary>
 /// <param name="metrics">The observed regression evaluation metric</param>
 public override void Add(RegressionMetrics metrics)
 {
     L1.Add(metrics.MeanAbsoluteError);
     L2.Add(metrics.MeanSquaredError);
     Rms.Add(metrics.RootMeanSquaredError);
     LossFn.Add(metrics.LossFunction);
     RSquared.Add(metrics.RSquared);
 }
 private void Carga_L1()
 {
     L1.Clear();
     foreach (object item in ListDetExc.Items)
     {
         L1.Items.Add(Funciones.DameNomDet(item.ToString()));
     }
 }
 /// <summary>
 /// Add a set of evaluation metrics to the set of observations.
 /// </summary>
 /// <param name="metrics">The observed regression evaluation metric</param>
 public override void Add(RegressionMetrics metrics)
 {
     L1.Add(metrics.L1);
     L2.Add(metrics.L2);
     Rms.Add(metrics.Rms);
     LossFn.Add(metrics.LossFn);
     RSquared.Add(metrics.RSquared);
 }
Example #18
0
 private void LastExecutedCommand()
 {
     TbMR2n.Text = N.ToString();
     TbMR2x.Text = X1.ToString();
     TbMR2y.Text = Y1.ToString();
     TbMR2t.Text = T1.ToString();
     TbMR2g.Text = G1.ToString();
     TbMR2l.Text = L1.ToString();
 }
Example #19
0
 public void Purge_parts_to_shared_storage()
 {
     purgingPartsToSharedStorage = true;
     Debug.Log("PURGE WORKSHOP: " + workshopIndex);
     Factory.INSTANCE.L3.Await_purged_data();
     L2.Await_purged_data();
     L1.Await_purged_data();
     REG.Await_purged_data();
 }
Example #20
0
 /// <summary>
 /// 设置精度
 /// </summary>
 /// <param name="n1">角度保留到小数点后的位数</param>
 /// <param name="n2">方位角保留到小数点后的位数</param>
 /// <param name="n3">大地线长度保留到小数点后的位数</param>
 public void SetAccurate(int n1, int n2, int n3)
 {
     B1.Set_Accurate(n1);
     L1.Set_Accurate(n1);
     A12.Set_Accurate(n2);
     B2.Set_Accurate(n1);
     L2.Set_Accurate(n1);
     A21.Set_Accurate(n2);
     S = Methods.Set_Accurate(S, n3);
 }
Example #21
0
 /// <summary>
 /// 得到四大车的工作车;(需要在一个计时器中)
 /// </summary>
 public void GetAllJobAndNonJobCar()
 {
     TJob.GetCopy((Tjc)T1.GetJobCar(CarsLst[0], CarsLst[1], Addrs.TRoomNumDic));
     LJob.GetCopy((Ljc)L1.GetJobCar(CarsLst[2], CarsLst[3], Addrs.LRoomNumDic));
     XJob.GetCopy((Xjc)X1.GetJobCar((Xjc)CarsLst[4], (Xjc)CarsLst[5]));
     //20171124 得到平煤的工作推焦车
     TNonJob.GetCopy(TJob.CarNum == 1 ? T2 : T1);
     LNonJob.GetCopy(LJob.CarNum == 1 ? L2 : L1);
     XNonJob.GetCopy(XJob.CarNum == 1 ? X2 : X1);
 }
        public void L1Test()
        {
            const double lambda = 1.0;
            var          reg    = new L1();
            var          mat    = new Matrix(10, 10);

            mat.InRandomize();

            Assert.IsTrue(Math.Abs(mat.AbsoluteNorm() * lambda - reg.CalculateNorm(mat)) < 0.1, reg.Type().ToString() + " Regularization.");
        }
Example #23
0
    public void Clear_all_requests_then_idle()
    {
        L2.Clear_all_requests();
        L1.Clear_all_requests();
        REG.Clear_all_requests();

        REG.Change_state(StorageState.IDLE);
        L1.Change_state(StorageState.IDLE);
        L2.Change_state(StorageState.IDLE);
    }
Example #24
0
        /// <summary>
        ///     Takes Frequency Value and Establishes Parent/Child relationship with Tree Nodes & Leafs
        /// </summary>
        /// <returns></returns>
        private bool BuildTree()
        {
            //Local Variables
            var iParentIndex = 0;

            var         OptimizedTree = new List <Leaf>(HuffmanTree);
            List <Leaf> WorkingTree;
            Leaf        NewParent;

            //Remove anything with a 0 Frequency Value
            OptimizedTree.RemoveAll(delegate(Leaf leaf) { return(leaf.FrequencyValue == 0); });

            //Order with highest frequency at 'end', lowest at 'beginning'
            OptimizedTree.Sort(delegate(Leaf L1, Leaf L2) { return(L1.FrequencyValue.CompareTo(L2.FrequencyValue)); });

            WorkingTree = new List <Leaf>(OptimizedTree);
            while (WorkingTree.Count > 1)
            {
                //Sort by Frequency
                //Order with highest frequency at 'end', lowest at 'beginning'
                WorkingTree.Sort(delegate(Leaf L1, Leaf L2) { return(L1.FrequencyValue.CompareTo(L2.FrequencyValue)); });

                //Take 'First Two' and join them with a new node
                NewParent = new Leaf {
                    FrequencyValue = WorkingTree[0].FrequencyValue + WorkingTree[1].FrequencyValue, IsNode = true
                };

                HuffmanTree.Add(NewParent);

                //Assign Parent to Left Node
                iParentIndex = HuffmanTree.FindIndex(delegate(Leaf L1) { return(L1.Equals(WorkingTree[0])); });
                HuffmanTree[iParentIndex].Left     = true;
                HuffmanTree[iParentIndex].ParentID = NewParent.ID;

                //Assign Parent to Right Node
                iParentIndex = HuffmanTree.FindIndex(delegate(Leaf L1) { return(L1.Equals(WorkingTree[1])); });
                HuffmanTree[iParentIndex].Right    = true;
                HuffmanTree[iParentIndex].ParentID = NewParent.ID;

                OptimizedTree = new List <Leaf>(HuffmanTree);

                //Remove anything with a 0 Frequency Value
                OptimizedTree.RemoveAll(delegate(Leaf leaf) { return(leaf.FrequencyValue == 0); });

                //Order with highest frequency at 'end', lowest at 'beginning'
                OptimizedTree.Sort(delegate(Leaf L1, Leaf L2) { return(L1.FrequencyValue.CompareTo(L2.FrequencyValue)); });

                WorkingTree = new List <Leaf>(OptimizedTree);

                //Remove anything with a parent
                WorkingTree.RemoveAll(delegate(Leaf leaf) { return(leaf.ParentID != new Guid()); });
            }

            return(true);
        }
 public TextBook(string _userid)
 {
     InitializeComponent();
     L1.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 1));
     L2.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 2));
     LK.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 3));
     PractZ.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 4));
     CourcePr.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 5));
     Import.AppendText(ViewModel.TextBookViewModel.UserText(_userid, 6));
     UserId = _userid;
 }
Example #26
0
        public BackPropagation GetLearningMethod(object owner, IContextLookup globalVars, BasicNetwork theNetwork,
                                                 IList <BasicData> data)
        {
            double theLearningRate = LearningRate.GetValue(owner, globalVars);
            double theMomentum     = Momentum.GetValue(owner, globalVars);
            var    theL1           = L1.GetValue(owner, globalVars);
            var    theL2           = L2.GetValue(owner, globalVars);
            var    toReturn        = new BackPropagation(theNetwork, data, theLearningRate, theMomentum);

            toReturn.L1 = theL1;
            toReturn.L2 = theL2;
            return(toReturn);
        }
 public SignUpAdmin()
 {
     InitializeComponent();
     foreach (Control c in Controls)
     {
         c.Hide();
     }
     title.Show();
     L1.Show();
     button_Back.Show();
     Verify.Show();
     Access.Show();
 }
Example #28
0
        private void cbox_Eq_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbox_Eq.Text.Trim() != "")
            {
                lbox_UsedAlg.Items.Clear();
                //FreshLbox("EquipName", "EquipAlgSlet", "lbox_UsedAlg");
                dataset.Clear();
                dataset = ServiceContainer.GetService <IGasDAL>().QueryData("AlgName", "EquipAlgSlet", "EquipName", cbox_Eq.Text);

                int j = 0;
                foreach (DataRow dr in dataset.Tables[0].Rows)
                {
                    lbox_UsedAlg.Items.Add(dataset.Tables[0].Rows[j][0]);
                    j++;
                }



                lbox_Factor.Items.Clear();
                lbox_UsedFact.Items.Clear();

                string L1, L2, L3;

                dataset.Clear();
                dataset = ServiceContainer.GetService <IGasDAL>().QueryData("L1", "EquipTypeSlet", "EquipName", cbox_Eq.Text);
                L1      = dataset.Tables[0].Rows[0][0].ToString();
                string[] L1D = L1.Split(';');
                for (int i = 0; i < L1D.Count() - 1; i++)
                {
                    lbox_Factor.Items.Add(L1D[i]);
                }

                dataset.Clear();
                dataset = ServiceContainer.GetService <IGasDAL>().QueryData("L2", "EquipTypeSlet", "EquipName", cbox_Eq.Text);
                L2      = dataset.Tables[0].Rows[0][0].ToString();
                string[] L2D = L2.Split(';');
                for (int i = 0; i < L2D.Count() - 1; i++)
                {
                    lbox_Factor.Items.Add(L2D[i]);
                }

                dataset.Clear();
                dataset = ServiceContainer.GetService <IGasDAL>().QueryData("L3", "EquipTypeSlet", "EquipName", cbox_Eq.Text);
                L3      = dataset.Tables[0].Rows[0][0].ToString();
                string[] L3D = L3.Split(';');
                for (int i = 0; i < L3D.Count() - 1; i++)
                {
                    lbox_Factor.Items.Add(L3D[i]);
                }
            }
        }
Example #29
0
        /// <summary>
        /// 创建treeview
        /// </summary>
        /// <param name="datasetALL">整表信息</param>
        private void FreshTree(DataSet datasetALL)
        {
            Tree_Factor.Nodes.Clear();
            int j = 0;

            foreach (DataRow dr in datasetALL.Tables[0].Rows)
            {
                //string ii= datasetALL.Tables[0].Rows[j]["Selected"].ToString();
                //if (datasetALL.Tables[0].Rows[j]["Selected"].ToString() == "True")
                //{}
                TreeNode tn = Tree_Factor.Nodes.Add(datasetALL.Tables[0].Rows[j]["EquipName"].ToString());

                string L1, L2, L3;

                TreeNode tn1 = new TreeNode("直采数据");
                tn.Nodes.Add(tn1);
                L1 = datasetALL.Tables[0].Rows[j]["L1"].ToString();
                string[] L1D = L1.Split(';');
                for (int i = 0; i < L1D.Count() - 1; i++)
                {
                    TreeNode tn12 = new TreeNode(L1D[i]);
                    tn1.Nodes.Add(tn12);
                }

                TreeNode tn2 = new TreeNode("操作数据");
                tn.Nodes.Add(tn2);
                L2 = datasetALL.Tables[0].Rows[j]["L2"].ToString();
                string[] L2D = L2.Split(';');
                for (int i = 0; i < L2D.Count() - 1; i++)
                {
                    TreeNode tn22 = new TreeNode(L2D[i]);
                    tn2.Nodes.Add(tn22);
                }

                TreeNode tn3 = new TreeNode("调度数据");
                tn.Nodes.Add(tn3);
                L3 = datasetALL.Tables[0].Rows[j]["L3"].ToString();
                string[] L3D = L3.Split(';');
                for (int i = 0; i < L3D.Count() - 1; i++)
                {
                    TreeNode tn32 = new TreeNode(L3D[i]);
                    tn3.Nodes.Add(tn32);
                }


                j++;
            }
        }
        public SignUpEmployee(int i)
        {
            controllerObj = new Controller();
            InitializeComponent();
            ID = i;
            L1.Hide();
            Verify.Hide();
            Access.Hide();
            Btn_SignUp.Hide();
            label1.Hide();
            TxtBox_PassAgain.Hide();
            checkBox_Devil.Hide();
            Save.Visible            = true;
            TxtBx_pass.PasswordChar = '\0';

            DataTable dt = controllerObj.SelectEmployeeByID(ID);

            TxtBx_Nationalid.Text = Convert.ToString(dt.Rows[0]["National ID"]);
            TxtBx_pass.Text       = Convert.ToString(dt.Rows[0]["Password"]);
            string name = Convert.ToString(dt.Rows[0]["Name"]);

            string[] words = name.Split(' ');
            textBox_Firstname.Text = words[0];
            textBox_Lastname.Text  = words[1];
            if (Convert.ToString(dt.Rows[0]["Sex"]) == "Male")
            {
                radioButton_Male.Checked = true;
            }
            else
            {
                radioButton_Female.Checked = true;
            }
            if (Convert.ToString(dt.Rows[0]["Position"]) == "Manager")
            {
                radioButton_Manager.Checked = true;
            }
            else if (Convert.ToString(dt.Rows[0]["Position"]) == "Projects")
            {
                radioButton_Projects.Checked = true;
            }
            else
            {
                radioButton_Housing.Checked = true;
            }
            dateTimePicker1.Value = Convert.ToDateTime(dt.Rows[0]["Start Date"]);
            Current.Value         = Convert.ToInt32(dt.Rows[0]["Number of Current Projects"]);
            Complete.Value        = Convert.ToInt32(dt.Rows[0]["Number of Completed Projects"]);
        }