Exemplo n.º 1
0
        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <param name="type">更新策略</param>
        /// <returns>修改是否成功</returns>
        public bool Update(T model, OptType type)
        {
            Fields fields = EntityUtil.GetFieldsByType(model.GetType());
            List <AssociationAttribute> assocations = fields.AssociationFields;

            return(Persist(new OptEntity(model, type), assocations));
        }
 public SAProblem(float2 interval, int sampleNum, OptType type = OptType.Swimming) : base()
 {
     this.state = new ActivationState(new Parameter()
     {
         interval = interval, sampleNum = sampleNum, type = type
     });
 }
Exemplo n.º 3
0
 void OnOperate(OptType type)
 {
     if (Operate != null)
     {
         Operate(type);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取UpdateSQL语句
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <param name="allowNull">是否允许值为null的属性(true:为null的属性赋空值;false:忽略为null的属性不做处理,保持数据库原样)</param>
        private string getUpdateSQL(EntityBase entity, OptType allowNull)
        {
            condition = "";

            foreach (DataField field in EntityUtil.GetDataFields(entity))//构造SQL参数集合
            {
                pars.Add(SQLFactory.CreateParameter(field.FieldName, field.FieldValue));
                //pars.Add(new SqlParameter(field.FieldName, field.FieldValue));

                if (EntityUtil.GetPrimaryKey(tableName).Contains(field.FieldName))
                {
                    condition += field.FieldName + "=@" + field.FieldName + " AND ";
                }
                else
                {
                    if (!field.IsIdentity)
                    {
                        if (field.FieldValue == null && allowNull != OptType.UpdateAllowedNull)
                        {
                            continue;
                        }
                        else
                        {
                            fs.Append(field.FieldName + "=@" + field.FieldName + ",");
                        }
                    }
                }
            }

            return(String.Format(updateSQL, tableName, fs.ToString().Trim(','), condition.Substring(0, condition.LastIndexOf("AND"))));//生成UPDATE语句
        }
Exemplo n.º 5
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            var other = obj as OptimizationKey;

            if (other == null)
            {
                throw new ArgumentException(Resources.OptimizationKey_CompareTo_Cannot_compare_OptimizationKey_to_an_object_of_a_different_type);
            }
            else if (!Equals(OptType, other.OptType))
            {
                return(OptType.CompareTo(other.OptType));
            }
            else if (!Equals(PeptideModSeq, other.PeptideModSeq))
            {
                return(PeptideModSeq.CompareTo(other.PeptideModSeq));
            }
            else if (!PrecursorAdduct.Equals(other.PrecursorAdduct))
            {
                return(PrecursorAdduct.CompareTo(other.PrecursorAdduct));
            }
            else if (FragmentIon != other.FragmentIon)
            {
                return(String.Compare(FragmentIon, other.FragmentIon, StringComparison.InvariantCulture));
            }
            else
            {
                return(ProductAdduct.CompareTo(other.ProductAdduct));
            }
        }
Exemplo n.º 6
0
 protected OptBase(OptType type, double lr, double clipRange, double l2RegFactor)
 {
     ClipRange    = clipRange;
     L2RegFactor  = l2RegFactor;
     LearningRate = lr;
     Type         = type;
 }
Exemplo n.º 7
0
        // defaults
        public Config()
        {
            TrainingThreads = 1;
            MinibatchSize   = 10;
            MaxEpoch        = 20;
            IterPerEpoch    = 11;
            LearningRate    = 0.001;
            LabelCount      = 10;
            DecayRate       = 0.9;
            Eps             = 1e-6;
            L2RegFactor     = 0;
            DropProb        = 0;
            ClipBound       = 5;
            HiddenSize      = 500;
            Layer           = 3;

            TrainTop       = 30;
            DataSeqScale   = 1;
            TrainFile      = "train-images.idx3-ubyte";
            TrainLabelFile = "train-labels.idx1-ubyte";
            TestFile       = "t10k-labels.idx1-ubyte";
            TestLabelFile  = "t10k-images.idx3-ubyte";

            NetType    = NetType.mlp;
            OptType    = OptType.adam;
            TrainType  = TrainType.minibatch;
            RandomSeed = 1300012976;
        }
Exemplo n.º 8
0
 public Config()
 {
     WordCutOff    = 1;
     InitRange     = 0.01f;
     MinibatchSize = 1;
     MaxEpoch      = 20;
     IterPerEpoch  = 1;
     LearningRate  = 0.001f;
     DecayRate     = 0.09f;
     Eps           = 1e-8f;
     L2RegFactor   = 1e-8f;
     ClipBound     = 5;
     HiddenSize    = 200;
     EmbeddingSize = 50;
     Seed          = 12976;
     UseCpos       = false;
     TrainFile     = null;
     DevFile       = null;
     TestFile      = null;
     EmbedFile     = null;
     OptType       = OptType.adam;
     OraType       = ArcStd.ArcStandardConfig.OracleType.standard;
     Model         = null;
     Mode          = RunMode.train;
 }
Exemplo n.º 9
0
        public int TrainTop;          // k in meProp (top or rand)


        public Config()
        {
            MinibatchSize  = 100;
            MaxEpoch       = 20;
            IterPerEpoch   = 8;
            LearningRate   = 0.001f;
            LabelCount     = 10;
            DecayRate      = 0.09f;
            Eps            = 1e-6f;
            L2RegFactor    = 0f;
            ClipBound      = 5;
            HiddenSize     = 500;
            TrainTop       = 160;
            Prune          = 0.1f;
            TrainFile      = null;
            TrainLabelFile = null;
            TestFile       = null;
            TestLabelFile  = null;
            TrainCycle     = 5;
            RandomSeed     = -1;
            Layers         = 3;

            NetType = NetType.mlp;
            OptType = OptType.adam;
        }
Exemplo n.º 10
0
 protected OptBase(OptType type, float lr, float clipRange, float l2RegFactor)
 {
     ClipRange    = clipRange;
     L2RegFactor  = l2RegFactor;
     LearningRate = lr;
     _type        = type;
 }
Exemplo n.º 11
0
        public static int GetIntOpt(OptType op)
        {
            string s = GetStrOpt(op);
            int    r = 0;

            int.TryParse(s, out r);
            return(r);
        }
Exemplo n.º 12
0
 public override void SetCannotFlag(CannotFlag flag, OptType type, bool cannot)
 {
     if (flag == CannotFlag.CannotControl && cannot)
     {
         IsControl = false;
     }
     base.SetCannotFlag(flag, type, cannot);
 }
Exemplo n.º 13
0
        // Token: 0x060005A9 RID: 1449 RVA: 0x0000CF68 File Offset: 0x0000B168
        public AppConditions addCondition(string key, List <string> values, OptType optType)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("key", key);
            dictionary.Add("values", values);
            dictionary.Add("optType", optType);
            condition.Add(dictionary);
            return(this);
        }
Exemplo n.º 14
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("OptieID", OptieID);
     writer.WriteAttributeString("Omschrijving", Omschrijving);
     writer.WriteAttributeString("standaard", standaard.ToString());
     writer.WriteAttributeString("BasisPrijs", BasisPrijs.ToString());
     writer.WriteAttributeString("PakketPg", PakketPg);
     writer.WriteAttributeString("OptieSoort", OptieSoort);
     writer.WriteAttributeString("OptType", OptType.ToString());
 }
Exemplo n.º 15
0
 /// <summary>
 /// 添加或修改(自动判断对象是否存在)
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <param name="type">更新策略</param>
 /// <returns>执行是否成功</returns>
 public bool AddOrUpdate(T model, OptType type)
 {
     if (!Exist(model))
     {
         return(Add(model));
     }
     else
     {
         return(Update(model, type));
     }
 }
Exemplo n.º 16
0
 public void Send(OptType opt)
 {
     try
     {
         ASCIIEncoding encoding = new ASCIIEncoding();
         byte[]        sb       = encoding.GetBytes(FormatData(opt));
         _ws.Send(sb);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 /// <summary>
 /// 优化滚动条显示类
 /// </summary>
 private OptimizeScrollView(OptType optType, string name)
 {
     this.name    = name;
     this.optType = optType;
     if ((optType & OptType.ColOnly) == OptType.ColOnly)
     {
         colEndPosition = new List <float>();
     }
     if ((optType & OptType.RowOnly) == OptType.RowOnly)
     {
         rowEndPosition = new List <float>();
         rowsHeight     = new List <float>();
     }
 }
Exemplo n.º 18
0
    public void on_sync_last_logic_frame(OptionEvent opt)
    {
        OptType opt_type = (OptType)opt.opt_type;

        switch (opt_type)
        {
        case OptType.JoyStick:
            this.sync_last_joystic_event(opt);
            break;

        default:
            break;
        }
    }
Exemplo n.º 19
0
    public virtual void SetCannotFlag(CannotFlag flag, OptType type, bool cannot)
    {
        int mask = mCannotFlag[(int)flag];

        if (cannot)
        {
            mask |= (1 << (int)type);
        }
        else
        {
            mask &= ~(1 << (int)type);
        }
        mCannotFlag[(int)flag] = mask;
    }
Exemplo n.º 20
0
        //private static int _sendCommRqDataCount = 0;
        //private static DateTime firstSendTime;

        public static string RetStockCodeBysRqName(OptType optType, string sRQName)
        {
            string[] sRQNameArray = sRQName.ToString().Trim().Split(',');
            string   stockCode    = "";

            switch (optType)
            {
            case OptType.Opt10001:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt10005:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt10015:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt10081:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt10060:
                stockCode = sRQNameArray[2];
                break;

            case OptType.Opt10014:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt20068:
                stockCode = sRQNameArray[4];
                break;

            case OptType.Opt10086:
                stockCode = sRQNameArray[1];
                break;

            case OptType.Opt90002:
                stockCode = sRQNameArray[2];
                break;

            default:
                break;
            }

            return(stockCode);
        }
Exemplo n.º 21
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (PeptideModSeq != null ? PeptideModSeq.GetHashCode() : 0);
         result = (result * 397) ^ OptType.GetHashCode();
         result = (result * 397) ^ PrecursorAdduct.GetHashCode();
         if (FragmentIon != null)
         {
             result = (result * 397) ^ FragmentIon.GetHashCode();
         }
         result = (result * 397) ^ ProductAdduct.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 22
0
        public string FormatData(string data, OptType opt)
        {
            string format_data = "";

            switch (opt)
            {
            case OptType.SERIALDATA:
                format_data = req_header + "::SERIALDATA::" + data;
                break;

            default:
                format_data = "";
                break;
            }
            return(format_data);
        }
Exemplo n.º 23
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            var other = obj as OptimizationKey;

            if (other == null)
            {
                return(false);
            }
            return(OptType.Equals(other.OptType) &&
                   Equals(PeptideModSeq, other.PeptideModSeq) &&
                   Equals(PrecursorAdduct, other.PrecursorAdduct) &&
                   FragmentIon == other.FragmentIon &&
                   Equals(ProductAdduct, other.ProductAdduct));
        }
        /// <summary>
        /// 根据名称获取滚动视图优化类的实例
        /// </summary>
        /// <param name="name">实例名字</param>
        /// <returns>类实例</returns>
        public static OptimizeScrollView GetInstance(string name, OptType optType = OptType.All)
        {
            if (instances == null)
            {
                instances = new Dictionary <string, OptimizeScrollView>();
            }

            if (!instances.TryGetValue(name, out OptimizeScrollView instance))
            {
                instance        = new OptimizeScrollView(optType, name);
                instances[name] = instance;
            }
            if (instance.optType != optType)
            {
                throw new InvalidOperationException($"{name}: Inconsistent Instance OptType {optType} : Maybe It Should Be {instance.optType}?");
            }

            return(instance);
        }
Exemplo n.º 25
0
        private void InitNet(NetType netType, OptType optType)
        {
            switch (optType)
            {
            case OptType.sgd:
                Opt = new Sgd(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.DecayRate,
                              _dataset.Examples.Count);
                break;

            case OptType.adagrad:
                Opt = new AdaGrad(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.Eps);
                break;

            case OptType.adam:
                Opt = new Adam(l2RegFactor: _conf.L2RegFactor, clipRange: _conf.ClipBound);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(optType), optType, null);
            }

            var eDim = _dataset.Examples[0].Feature.Length;
            var hDim = _conf.HiddenSize;
            var oDim = _conf.LabelCount;

            switch (netType)
            {
            case NetType.mlp:
                Net = new MLP(_conf, eDim, Opt);
                break;

            case NetType.mlptop:
                Net = new MLPTop(_conf, eDim, Opt);
                break;

            case NetType.mlprand:
                Net = new MLPRand(_conf, eDim, Opt);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(netType), netType, null);
            }
        }
Exemplo n.º 26
0
        private void InitNet(NetType netType, OptType optType)
        {
            switch (optType)
            {
            case OptType.sgd:
                Opt = new Sgd(Global.Config.LearningRate, Global.Config.L2RegFactor, Global.Config.ClipBound, Global.Config.DecayRate,
                              _dataset.Examples.Count);
                break;

            case OptType.adagrad:
                Opt = new AdaGrad(Global.Config.LearningRate, Global.Config.L2RegFactor, Global.Config.ClipBound, Global.Config.Eps);
                break;

            case OptType.adam:
                Opt = new Adam(Global.Config.LearningRate, Global.Config.L2RegFactor, Global.Config.ClipBound, 0.999f, 0.9f, 1e-8f);
                break;;

            default:
                throw new ArgumentOutOfRangeException(nameof(optType), optType, null);
            }

            var eDim = Global.Config.TokenCount * Global.Config.EmbeddingSize;
            var hDim = Global.Config.HiddenSize;
            var oDim = _labelCount;

            switch (netType)
            {
            case NetType.ffnn:
                Net = new FFNN(eDim, hDim, oDim, Opt);
                break;

            case NetType.blstm:
                Net = new Blstm(eDim, hDim, oDim, Opt);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(netType), netType, null);
            }

            Net.InitEmbed(_embedd);
        }
Exemplo n.º 27
0
 public string Send(string data, OptType opt)
 {
     try
     {
         ASCIIEncoding encoding = new ASCIIEncoding();
         req        = (HttpWebRequest)WebRequest.Create(url);
         req.Method = "POST";
         var    ReqStream = req.GetRequestStream();
         byte[] sendByte  = encoding.GetBytes(FormatData(data, opt));
         ReqStream.Write(sendByte, 0, sendByte.Length);
         resp = req.GetResponse();
         var          st     = resp.GetResponseStream();
         StreamReader stread = new StreamReader(st);
         return(stread.ReadToEnd());
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return("");
     }
 }
Exemplo n.º 28
0
        private static string getDefVal(OptType tp)
        {
            switch (tp)
            {
            case OptType.ScaleAddres: return("192.168.0.5");

            case OptType.ScalePort: return("8111");

            case OptType.ScanPLUFrom: return("1");

            case OptType.ScanPLUUntil: return("10");

            case OptType.ScanMSGFrom: return("1");

            case OptType.ScanMSGUntil: return("20");

            case OptType.ScanDelay: return("5");

            case OptType.Monitoring: return("0");
            }
            return("");
        }
Exemplo n.º 29
0
    public void on_handler_frame_event(OptionEvent opt)
    {
        OptType opt_type = (OptType)opt.opt_type;

        switch (opt_type)
        {
        case OptType.JoyStick:
            this.handle_joystic_event(opt);
            break;

        case OptType.Attack:
            this.do_attack();
            break;

        case OptType.Skill1:
            this.do_skill1();
            break;

        default:
            break;
        }
    }
Exemplo n.º 30
0
        // build a optimizer
        private void InitOpt(OptType optType)
        {
            switch (optType)
            {
            case OptType.sgd:
                Opt = new Sgd(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.DecayRate,
                              _dataset.Examples.Count);
                break;

            case OptType.adagrad:
                Opt = new AdaGrad(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.Eps);
                break;

            case OptType.adam:
                Opt = new Adam(l2RegFactor: _conf.L2RegFactor, clipRange: _conf.ClipBound);
                break;

            default:
                // should never reach this
                throw new ArgumentOutOfRangeException(nameof(optType), optType, null);
            }
        }
Exemplo n.º 31
0
 public opt(OptType t, object c, TomShane.Neoforce.Controls.EventHandler e = null)
 {
     if (c.GetType() != tc[t]) throw new System.ArgumentException("Content does not match option type");
     type = t; content = c; action = e ?? action;
 }