Пример #1
0
        public static void InsertQState(string state, string stra, double value)
        {
            WhiteQlearningDataContext whiteQlearning = new WhiteQlearningDataContext();
            int sno = whiteQlearning.STATEs.Where(p => p.MSTATE == state).Single().SNO;
            int ano = whiteQlearning.ASTRATEGies.Where(p => p.STRATEGY == stra).Single().ANO;

            if (!whiteQlearning.QSTATEs.Any(p => p.SNO == sno && p.ANO == ano))
            {
                QSTATE tmps = new QSTATE();
                tmps.SNO = sno;
                tmps.ANO = ano;
                tmps.VALUE = value;
                whiteQlearning.QSTATEs.InsertOnSubmit(tmps);
                whiteQlearning.SubmitChanges();
            }
            else
            {
                whiteQlearning.QSTATEs.Where(p => p.SNO == sno && p.ANO == ano).Single().VALUE = value;
                whiteQlearning.SubmitChanges();
            }
        }
Пример #2
0
        //public static void InsertProb(string state, string stra, string nstate)
        //{
        //    WhiteQlearningDataContext whiteQlearning = new WhiteQlearningDataContext();
        //    int sno = whiteQlearning.STATEs.Where(p => p.MSTATE == state).Single().SNO;
        //    int ano = whiteQlearning.ASTRATEGies.Where(p => p.STRATEGY == stra).Single().ANO;
        //    int nsno = whiteQlearning.STATEs.Where(p => p.MSTATE == nstate).Single().SNO;

        //    if (!whiteQlearning.PROBs.Any(p => p.SNO == sno && p.ANO == ano && p.NSNO == nsno))
        //    {
        //        PROB tmps = new PROB();
        //        tmps.SNO = sno;
        //        tmps.ANO = ano;
        //        tmps.NSNO = nsno;
        //        tmps.TIMES = 1;
        //        whiteQlearning.PROBs.InsertOnSubmit(tmps);
        //        whiteQlearning.SubmitChanges();
        //    }
        //    else
        //    {
        //        whiteQlearning.PROBs.Where(p => p.SNO == sno && p.ANO == ano && p.NSNO == nsno).Single().TIMES++;
        //        whiteQlearning.SubmitChanges();
        //    }
       // }

        public static double SelectQState(string state, string stra)
        {
            double value;
            WhiteQlearningDataContext whiteQlearning = new WhiteQlearningDataContext();
            int sno = whiteQlearning.STATEs.Where(p => p.MSTATE == state).Single().SNO;
            int ano = whiteQlearning.ASTRATEGies.Where(p => p.STRATEGY == stra).Single().ANO;

            var tmp = from c in whiteQlearning.QSTATEs
                      where c.SNO == sno && c.ANO == ano
                      select c.VALUE;

            if (tmp.Count() <= 0)
            {
                QSTATE tmps = new QSTATE();
                tmps.SNO = sno;
                tmps.ANO = ano;
                tmps.VALUE = 1.0;
                whiteQlearning.QSTATEs.InsertOnSubmit(tmps);
                whiteQlearning.SubmitChanges();
                value = 1.0;
            }
            else value = tmp.Single();
            return value;
        }
		private void detach_QSTATEs(QSTATE entity)
		{
			this.SendPropertyChanging();
			entity.STATE = null;
		}
		private void attach_QSTATEs(QSTATE entity)
		{
			this.SendPropertyChanging();
			entity.STATE = this;
		}
 partial void DeleteQSTATE(QSTATE instance);
 partial void UpdateQSTATE(QSTATE instance);
 partial void InsertQSTATE(QSTATE instance);