当前位置: 首页>>代码示例>>C#>>正文


C# Decision.GetDouble方法代码示例

本文整理汇总了C#中Decision.GetDouble方法的典型用法代码示例。如果您正苦于以下问题:C# Decision.GetDouble方法的具体用法?C# Decision.GetDouble怎么用?C# Decision.GetDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Decision的用法示例。


在下文中一共展示了Decision.GetDouble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OptFunc


//.........这里部分代码省略.........
                   I4 - W4 + I5 - W5 + I6 - W6 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 + I11 - W11 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 + I11 - W11 + I12 - W12 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 + I11 - W11 + I12 - W12 + I1 - W1 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 + I11 - W11 + I12 - W12 + I1 - W1 + I2 - W2 >= 0,
                   I4 - W4 + I5 - W5 + I6 - W6 + I7 - W7 + I8 - W8 + I9 - W9 + I10 - W10 + I11 - W11 + I12 - W12 + I1 - W1 + I2 - W2 + I3 - W3 == 0
                 );

                #endregion

                ty = matrix(monthspread);
                tv = new Term[,] { { (I4 - W4), (I5 - W5), (I6 - W6), (I7 - W7), (I8 - W8), (I9 - W9), (I10 - W10), (I11 - W11), (I12 - W12), (I1 - W1), (I2 - W2), (I3 - W3) } };

                //to create the goal we need to find the volumes for each month, if injection greater than
                //withdrawals vol is positive vica versa, then multiply by spread and reverse sign to find profit, which is what we want to maximise
                //goal = matMult(matSubtract(tx, tw), ty)[0, 0];
                goal = matMult(tv, ty)[0, 0];
                model.AddGoal("goal", GoalKind.Minimize, goal);

                // Specifying the IPM solver, as we have a quadratic goal
                Solution solution = context.Solve(new InteriorPointMethodDirective());

                //Profit calculation section, you need to store decisions and profit figures......

                //  DataSet SimulationResults = new DataSet();
                #region Fill DataSet

                DataRow rowinfo = Withtable.NewRow();

                rowinfo[0] = Convert.ToDouble(W4.GetDouble());
                rowinfo[1] = Convert.ToDouble(W5.GetDouble());
                rowinfo[2] = Convert.ToDouble(W6.GetDouble());
                rowinfo[3] = Convert.ToDouble(W7.GetDouble());
                rowinfo[4] = Convert.ToDouble(W8.GetDouble());
                rowinfo[5] = Convert.ToDouble(W9.GetDouble());
                rowinfo[6] = Convert.ToDouble(W10.GetDouble());
                rowinfo[7] = Convert.ToDouble(W11.GetDouble());
                rowinfo[8] = Convert.ToDouble(W12.GetDouble());
                rowinfo[9] = Convert.ToDouble(W1.GetDouble());
                rowinfo[10] = Convert.ToDouble(W2.GetDouble());
                rowinfo[11] = Convert.ToDouble(W3.GetDouble());
                SimulationResults.Tables[1].Rows.Add(rowinfo);

                rowinfo = Imptable.NewRow();
                rowinfo[0] = Convert.ToDouble(I4.GetDouble());
                rowinfo[1] = Convert.ToDouble(I5.GetDouble());
                rowinfo[2] = Convert.ToDouble(I6.GetDouble());
                rowinfo[3] = Convert.ToDouble(I7.GetDouble());
                rowinfo[4] = Convert.ToDouble(I8.GetDouble());
                rowinfo[5] = Convert.ToDouble(I9.GetDouble());
                rowinfo[6] = Convert.ToDouble(I10.GetDouble());
                rowinfo[7] = Convert.ToDouble(I11.GetDouble());
                rowinfo[8] = Convert.ToDouble(I12.GetDouble());
                rowinfo[9] = Convert.ToDouble(I1.GetDouble());
                rowinfo[10] = Convert.ToDouble(I2.GetDouble());
                rowinfo[11] = Convert.ToDouble(I3.GetDouble());
                SimulationResults.Tables[2].Rows.Add(rowinfo);

                rowinfo = Proftable.NewRow();
                rowinfo[0] = (Convert.ToDouble(W4.GetDouble()) - Convert.ToDouble(I4.GetDouble())) * PriceArray[0, 1]/100;
                rowinfo[1] = (Convert.ToDouble(W5.GetDouble()) - Convert.ToDouble(I5.GetDouble())) * PriceArray[1, 1]/100;
                rowinfo[2] = (Convert.ToDouble(W6.GetDouble()) - Convert.ToDouble(I6.GetDouble())) * PriceArray[2, 1]/100;
开发者ID:seanclogher,项目名称:Modelling-Tool,代码行数:67,代码来源:Optimisation.cs

示例2: RunSimplex

        private void RunSimplex(double avgViews, double totalStorage, IOrderedEnumerable<KeyValuePair<Event, double>> events)
        {
            var memcacheCost = .25;
            var memcacheCoefficient = .3;
            var discCost = .025;
            var discCoefficient = .1;
            var tapeCost = 0;
            var tapeCoefficient = 0;
            var memcacheValueCoefficient = .3;
            var discValueCoefficient = .1;
            var tapeValueCoefficient = 0;

            SolverContext context = SolverContext.GetContext();
            Model model = context.CreateModel();

            Decision memcache = new Decision(Domain.RealNonnegative, "gigs_memcache_storage");
            Decision disc = new Decision(Domain.RealNonnegative, "gigs_disc_storage");
            Decision tape = new Decision(Domain.RealNonnegative, "gigs_tape_storage");
            model.AddDecisions(memcache, disc, tape);

            model.AddConstraint("cost", (memcacheCost + memcacheCoefficient * avgViews) * memcache + (discCost + discCoefficient * avgViews) * disc + (tapeCost + tapeCoefficient * avgViews) * tape <= 16106127360);
            model.AddConstraint("total_storage", totalStorage == memcache + disc + tape);

            model.AddGoal("value", GoalKind.Maximize, memcacheValueCoefficient * memcache + discValueCoefficient * disc + tapeValueCoefficient * tape);

            Solution solution = context.Solve(new SimplexDirective());

            Log.InfoFormat("Results of linear optimization: Memcache={0} Disk={1} Tape={2}", memcache.GetDouble(), disc.GetDouble(), tape.GetDouble());
            AllocateMedia(events, memcache.GetDouble(), disc.GetDouble(), tape.GetDouble());
        }
开发者ID:ryanerdmann,项目名称:angora,代码行数:30,代码来源:SimplexService.cs


注:本文中的Decision.GetDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。