Beispiel #1
0
        /// <summary>
        /// Fill method for populating an entire collection of Valuations
        /// </summary>
        public virtual void Fill(Valuations valuations)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Valuation.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectValuations");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(valuations, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Valuations valuations, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            Valuation newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(valuations.ContainsType[0]) as Valuation;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                valuations.Add(newobj);
            }
        }
Beispiel #3
0
        private Valuation[] GetTopThreeValuations(double[] input, double[] output)
        {
            // The bestValuations is an array of the three best moves calculated by the neural network.
            Valuation[] bestValuations = { Valuation.InitialValuation, Valuation.InitialValuation, Valuation.InitialValuation };

            for (int i = 0; i < 64; i++)
            {
                if (input[i] != 0)
                {
                    continue;
                }

                double v = output[i];

                if (v > bestValuations[0].Value)
                {
                    bestValuations[2] = bestValuations[1];
                    bestValuations[1] = bestValuations[0];
                    bestValuations[0] = new Valuation(i, v);
                }
                else if (v > bestValuations[1].Value)
                {
                    bestValuations[2] = bestValuations[1];
                    bestValuations[1] = new Valuation(i, v);
                }
                else if (v > bestValuations[2].Value)
                {
                    bestValuations[2] = new Valuation(i, v);
                }
            }

            return(bestValuations);
        }
        public async Task <IHttpActionResult> PutValuation(int id, Valuation valuation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != valuation.Id)
            {
                return(BadRequest());
            }

            db.Entry(valuation).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ValuationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void RunRealtimeValuation(int valuationId)
        {
            ValuationStatus = "Running";
            Valuation valuation = _valuationRepo.GetValuation(valuationId);
            //retrieve portfolios
            List <Portfolio> portfolios = new List <Portfolio>();

            portfolios = _portfolioRepo.GetPortoflios();

            if (portfolios.Count == 0)
            {
                return;
            }
            //get realtime prices
            List <PriceValue> prices = _priceEngine.GetPrices(GetAllSymbolsFromPositions(portfolios));

            if (prices.Count <= 0)
            {
                return;
            }
            //save prices
            SavePriceValues(prices);
            //valuation positions
            ValuePositions(portfolios, prices, valuation.Id);
        }
Beispiel #6
0
        public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
        {
            //List<ConfigurationWithChannelData> list = new List<ConfigurationWithChannelData>(1);

            if (Specification.SyncrhonousChannelNames.Contains(ChannelName))
            {
                string eventName = ChannelName;
                string eventID   = ChannelName;

                Expression[] newExpressionList = new Expression[ExpressionList.Length];

                for (int i = 0; i < ExpressionList.Length; i++)
                {
                    newExpressionList[i] = EvaluatorDenotational.Evaluate(ExpressionList[i], GlobalEnv);
                    eventName           += "." + newExpressionList[i];
                    eventID += "." + newExpressionList[i].ExpressionID;
                }

                if (eventID != eventName)
                {
                    list.Add(new ConfigurationWithChannelData(Process, eventID, eventName, GlobalEnv, false, ChannelName, newExpressionList));
                }
                else
                {
                    list.Add(new ConfigurationWithChannelData(Process, eventID, null, GlobalEnv, false, ChannelName, newExpressionList));
                }
            }

            //return list;
        }
Beispiel #7
0
        public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
        {
            //List<ConfigurationWithChannelData> returnList = new List<ConfigurationWithChannelData>();

            for (int i = 0; i < Processes.Count; i++)
            {
                Process process = Processes[i];
                List <ConfigurationWithChannelData> list1 = new List <ConfigurationWithChannelData>();
                process.SyncOutput(GlobalEnv, list1);

                foreach (ConfigurationWithChannelData pair in list1)
                {
                    Configuration step = pair;

                    List <Process> newProcess = new List <Process>(Processes.Count);
                    newProcess.AddRange(Processes);
                    newProcess[i] = step.Process;

                    step.Process = new IndexInterleave(newProcess);
                }

                list.AddRange(list1);
            }

            //return returnList;
        }
Beispiel #8
0
        public CardForm(Card _card)
        {
            InitializeComponent();
            card = _card;
            Text = _card.Name;

            Valuation valuation = NetDecks.Valuations.FirstOrDefault(x => x.Card == card);

            if (valuation == null)
            {
                return;
            }
            {
                List <Deck> unique = valuation.Decks.OrderBy(x => x.Key.Tier).ThenBy(x => x.Key.MyDust).Select(x => x.Key).GroupBy(x => x.DuplicateIndicatior, (k, g) => g.First()).ToList();

                radGridView1.MasterTemplate.ShowRowHeaderColumn = false;
                radGridView1.DataSource = unique;
                radGridView1.Size       = new Size(Width, 30 + unique.Count * 23);
                Size        = new Size(Width, 100 + unique.Count * 23);
                label1.Text = $"{unique.Count} unique of {valuation.Decks.Count}";
                label2.Text = $"{unique.Count(x => x.MyDust == card.Dust)} / " +
                              $"{unique.Count(x => x.MyDust != card.Dust && x.Cards.First(y => y.Key == card).Value - card.Own > 0)} / " +
                              $"{unique.Count(x => card.Own >= x.Cards.First(y => y.Key == card).Value)}";
            }
        }
Beispiel #9
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            if (FirstProcess.IsSkip())
            {
                SecondProcess.MoveOneStep(GlobalEnv, list);
                return;
            }

            FirstProcess.MoveOneStep(GlobalEnv, list);
            for (int i = 0; i < list.Count; i++)
            {
                Configuration step = list[i];
                if (step.Event == Constants.TERMINATION)
                {
                    step.Event   = Constants.TAU;
                    step.Process = SecondProcess;
                }
                else
                {
                    Sequence p = new Sequence(step.Process, this.SecondProcess);
                    step.Process = p;
                }
                list[i] = step;
            }
        }
Beispiel #10
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            FirstProcess.MoveOneStep(GlobalEnv, list);

            for (int i = 0; i < list.Count; i++)
            {
                Configuration step = list[i];
                if (step.Event != Constants.TERMINATION)
                {
                    Interrupt inter = new Interrupt(step.Process, SecondProcess);
                    step.Process = inter;
                }
            }

            List <Configuration> list2 = new List <Configuration>();

            SecondProcess.MoveOneStep(GlobalEnv, list2);
            for (int i = 0; i < list2.Count; i++)
            {
                Configuration step = list2[i];
                if (step.Event == Constants.TAU)
                {
                    Interrupt inter = new Interrupt(FirstProcess, step.Process);

                    step.Process = inter;
                }

                list.Add(step);
            }

            //return returnList;
        }
Beispiel #11
0
        public void Should_return_0dot02_volumen_can_buy_when_have_1500_pln_on_index_DE30()
        {
            var symbol       = "DE30";
            var categoryName = CategoryName.Index;
            var contractSize = 25;
            var bidPrice     = 12265.3;
            var askPrice     = 12267.8;
            var currency     = "EUR";
            var laverage     = 5;
            var precision    = 1;
            var spread       = 1;

            var valuation = new Valuation(bidPrice, askPrice);

            var instrument = new Instrument(symbol, categoryName, currency, valuation, new TimeSpan(02, 00, 00));

            instrument.SetContractSize(contractSize);
            instrument.SetLeverage(laverage);
            instrument.SetPrecision(precision);
            instrument.SetSpread(spread);

            var volumeToBuy = instrument.ComputeVolumeToBuyByMaxPrice(1500, instrument.Valuation.BidPrice);

            Assert.Equal(0.02M, volumeToBuy);
        }
Beispiel #12
0
        public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
        {
            //List<ConfigurationWithChannelData> returnList = new List<ConfigurationWithChannelData>();

            for (int i = 0; i < Processes.Count; i++)
            {
                Process process = Processes[i];
                List <ConfigurationWithChannelData> list1 = new List <ConfigurationWithChannelData>();
                process.SyncOutput(GlobalEnv, list1);

                for (int j = 0; j < list1.Count; j++)
                {
                    Configuration step = list1[j];

                    List <Process> newProcess = new List <Process>(Processes.Count);
                    newProcess.AddRange(Processes);
                    newProcess[i] = step.Process;

                    step.Process = new IndexParallel(newProcess, Alphabets);
                }

                list.AddRange(list1);
            }
            //return returnList;
        }
Beispiel #13
0
    private int count = 0; // used for testing right mouse clicks

    private void Awake()
    {
        var vals = this.GetComponentsInChildren <Valuation>();

        this.firstValuation  = vals[0];
        this.secondValuation = vals[1];
    }
Beispiel #14
0
        public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
        {
            for (int i = 0; i < Processes.Count; i++)
            {
                Process process = Processes[i];
                List <ConfigurationWithChannelData> list1 = new List <ConfigurationWithChannelData>();
                process.SyncOutput(GlobalEnv, list1);

                if (list1.Count > 0)
                {
                    List <Dictionary <string, int> > nextProcessCounters =
                        Common.Classes.Ultility.Ultility.ProcessCounterDecrement(MustAbstract ? Common.Classes.Ultility.Ultility.CutNumber : -1, ProcessesCounter, process.ProcessID, 1);

                    for (int j = 0; j < list1.Count; j++)
                    {
                        ConfigurationWithChannelData step = list1[j];

                        foreach (Dictionary <string, int> ints in nextProcessCounters)
                        {
                            List <Process> newProcess = new List <Process>(Processes);

                            Dictionary <string, int> listInstance = new Dictionary <string, int>(ints);
                            AddOneProcess(newProcess, step.Process, listInstance);
                            IndexInterleaveAbstract      interleave = new IndexInterleaveAbstract(newProcess, listInstance);
                            ConfigurationWithChannelData newStep    = new ConfigurationWithChannelData(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation, list1[j].ChannelName, list1[j].Expressions);
                            newStep.IsAtomic = step.IsAtomic;
                            list.Add(newStep);
                        }
                    }
                }
            }
        }
        public override void Initialize(SpecificationBase spec)
        {
            //initialize the ModelCheckingOptions
            base.Initialize(spec);

            Specification Spec = spec as Specification;

            ReachableStateCondition = Spec.DeclarationDatabase[ReachableStateLabel];

            List <string> varList = Process.GetGlobalVariables();

            varList.AddRange(ReachableStateCondition.GetVars());
            varList.AddRange(ConstraintCondition.GetVars());

            Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(varList, Process.GetChannels());

            //Initialize InitialStep
            InitialStep = new Configuration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false);

            MustAbstract = Process.MustBeAbstracted();

            if (MustAbstract)
            {
                throw new ParsingException(
                          "Process " + StartingProcess +
                          " has infinite states and therefore can not be used to assert reachability with MIN/MAX constraints!",
                          AssertToken);
            }
        }
        private static Valuation CreateValuationFromXmlNode(XmlNode valuationNode)
        {
            DateTime date      = XmlHelper.GetNodeValueDate("Date", valuationNode);
            var      price     = new Decimal(XmlHelper.GetNodeValueDouble("Price", valuationNode));
            var      valuation = new Valuation(date, price);

            return(valuation);
        }
Beispiel #17
0
    private void Awake()
    {
        var vals = this.GetComponentsInChildren <Valuation>();

        this.firstValuation  = vals[0];
        this.secondValuation = vals[1];
        oracleAnimator       = GetComponent <Animator>();
    }
Beispiel #18
0
        /**
         * BASE CLASS VARIABLEs
         *
         * public string Event;
         * public string DisplayName;
         * public Valuation GlobalEnv; //-> the global variable
         *
         * public bool IsDeadLock; //-> fire to mark when checking Deadlock Assertion
         * public bool IsAtomic;
         * public bool IsDataOperation;
         * public string[] ParticipatingProcesses;
         */

        /// <summary>
        /// This constructor is called from the assertion to intial a configuration
        ///
        /// Status: incompleted: How to initial value for globalEnv
        /// </summary>
        /// <param name="p"></param>
        /// <param name="e"></param>
        /// <param name="displayName"></param>
        /// <param name="globalEnv"></param>
        /// <param name="isDataOperation"></param>
        public PNConfiguration(PetriNet p, string e, string displayName, Valuation globalEnv, bool isDataOperation)
        {
            Process         = p;
            Event           = e;//base event
            GlobalEnv       = globalEnv;
            DisplayName     = displayName;
            IsDataOperation = isDataOperation;
        }
Beispiel #19
0
 public Configuration(Process p, string e, string displayName, Valuation globalEnv, bool isDataOperation)
 {
     Process         = p;
     Event           = e;
     GlobalEnv       = globalEnv;
     DisplayName     = displayName;
     IsDataOperation = isDataOperation;
 }
Beispiel #20
0
 /// <summary>
 /// 属性赋值构造函数
 /// </summary>
 /// <param name="level">教材水平</param>
 /// <param name="service">出版社服务质量</param>
 /// <param name="apply">出版社影响力</param>
 /// <param name="pcount">应用面</param>
 public _Evaluaion(Valuation level, Valuation service, Valuation influ, Valuation apply)
 {
     Level          = level;
     ServiceQuality = service;
     Influence      = influ;
     Application    = apply;
     SetPrintingCount();
 }
Beispiel #21
0
 public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
 {
     Process.SyncOutput(GlobalEnv, list);
     foreach (ConfigurationWithChannelData step in list)
     {
         step.Process  = new AtomicProcess(step.Process);
         step.IsAtomic = true;
     }
 }
 public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
 {
     for (int i = 0; i < Processes.Count; i++)
     {
         List <ConfigurationWithChannelData> list1 = new List <ConfigurationWithChannelData>();
         Processes[i].SyncOutput(GlobalEnv, list1);
         list.AddRange(list1);
     }
 }
Beispiel #23
0
 public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
 {
     Process.SyncOutput(GlobalEnv, list);
     foreach (ConfigurationWithChannelData pair in list)
     {
         Configuration step = pair;
         step.Process = new Hiding(step.Process, HidingAlphabets);
     }
 }
Beispiel #24
0
        public static void Initialize(AssertionBase Assertion, PetriNet Process, SpecificationBase spec)
        {
            Specification Spec = spec as Specification;

            //get the relevant global variables; remove irrelevant variables so as to save memory;
            Valuation GlobalEnv = Spec.SpecValuation.GetClone();

            //Initialize InitialStep
            Assertion.InitialStep = new PNConfiguration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false, spec);
        }
Beispiel #25
0
 /// <summary>
 /// Add channel variable to model from channel delcaration in Valuation
 /// </summary>
 /// <param name="valuation"></param>
 public void AddGlobalChannel(Valuation valuation)
 {
     if (valuation.Channels != null && valuation.Channels.Count > 0)
     {
         foreach (KeyValuePair <string, ChannelQueue> pair in valuation.Channels)
         {
             model.AddGlobalChannel(pair.Key, pair.Value.Size);
         }
     }
 }
Beispiel #26
0
 protected void CheckVariableRange()
 {
     foreach (KeyValuePair <string, Declaration> declaration in DeclaritionTable)
     {
         if (declaration.Value.DeclarationType == DeclarationType.Variable)
         {
             Valuation.CheckVariableRange(declaration.Key, SpecValuation.Variables[declaration.Key], declaration.Value.DeclarationToken.Line, declaration.Value.DeclarationToken.CharPositionInLine);
         }
     }
 }
Beispiel #27
0
        public async Task <int> addValuations(Valuation valuation)
        {
            using (var db = new SqlConnection(LinkSQL))
            {
                var sql    = $@"INSERT INTO [dbo].[valuation] ([booksid],[content],[userName]) VALUES (@booksid,@content,@userName)";
                var result = await db.ExecuteAsync(sql, valuation);

                return(result);
            }
        }
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            ExpressionValue v = EvaluatorDenotational.Evaluate(ConditionalExpression, GlobalEnv);

            if ((v as BoolConstant).Value)
            {
                list.Add(new Configuration(FirstProcess, Constants.TAU, "[ifb(" + ConditionalExpression + ")]", GlobalEnv, false));
            }
        }
Beispiel #29
0
        public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list)
        {
            ExpressionValue v = EvaluatorDenotational.Evaluate(Condition, GlobalEnv);

            if ((v as BoolConstant).Value)
            {
                Process.SyncOutput(GlobalEnv, list);
            }

            //return new List<ConfigurationWithChannelData>(0);
        }
        public async Task <IHttpActionResult> GetValuation(int id)
        {
            Valuation valuation = await repo.GetValuationAsync(id);

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

            return(Ok(valuation));
        }
Beispiel #31
0
        private void button1_Click(object sender, EventArgs e)
        {
            //int il_atomow = (int)numericUpDown1.Value;

            string dictSeq =textBox1.Text;

            string dictSeq2 = textBox2.Text;

            int numberOfAtoms=(int)numericUpDown1.Value;

            //       Console.WriteLine("Ile atomów?");
            //     numberOfAtoms = Convert.ToInt32(Console.ReadLine());
            //numberOfAtoms = il_atomow;
            Valuation val = new Valuation(numberOfAtoms);
            Valuation.InterrConn Connn = new Valuation.InterrConn(Program.itIsNecessary);
            Valuation.Val Valuation = new Valuation.Val(Program.valVariables);

            try
            {

                string beta = textBox3.Text;

                string dictSequence = dictSeq;

                string dictSequence_var = dictSeq2;

                Dictionary<int, List<int>> Dict =
                    Program.toDictionary(dictSequence);
                Dictionary<string, int[]> Dict_var =
                   Program.toDictionary_str(dictSequence_var);

                Program.setDictNecess(Dict);
                Program.setDictValuaVar(Dict_var);
                Formula fromBeta = Program.ToFormula(beta);
                Set<int> Valua_beta = new Set<int>();
                Valua_beta = val.Valua(Connn, Valuation, fromBeta);
                if(Valua_beta.Elements.Count!=0)
                {
                Program.sort(ref Valua_beta);
                textBox4.Text = Valua_beta.ToString().Substring(0,Valua_beta.ToString().Length-3)+"}";
                }
                else textBox4.Text="{}";

            }
            catch
            {
                MessageBox.Show("Something is wrong with formats");}
        }