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


C# Decision.ToDouble方法代码示例

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


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

示例1: SimplexAllocate

        public SimplexDecision SimplexAllocate(double averageViews, double totalStorage)
        {
            /*
             * Goal is to maximize the storage constant
             *		storage constant = (memory constant) * (size in mem)
             *					+ (disk constant) * (size in disk)
             *					+ (tape constant) * (size in tape)
             */

            //Assuming value is proportional to cost
            double memConstant = 30,
                diskConstant = 10,
                tapeConstant = 0;

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

            Decision sizeMem = new Decision(Domain.RealNonnegative, "MemorySize");
            Decision sizeDisk = new Decision(Domain.RealNonnegative, "DiskSize");
            Decision sizeTape = new Decision(Domain.RealNonnegative, "TapeSize");

            model.AddDecisions(sizeMem, sizeDisk, sizeTape);

            model.AddConstraint("cost", 0 <= (0.25 + 0.3 * averageViews) * sizeMem + (0.025 + 0.1 * averageViews) * sizeDisk <= 15);
            model.AddConstraint("storage", totalStorage == sizeMem + sizeDisk + sizeTape);
            model.AddGoal("storageValue", GoalKind.Maximize, memConstant * sizeMem + diskConstant * sizeDisk + tapeConstant * sizeTape);

            Solution sol = solver.Solve(new SimplexDirective());

            return new SimplexDecision()
            {
                Memory = sizeMem.ToDouble(),
                Disk = sizeDisk.ToDouble(),
                Tape = sizeTape.ToDouble()
            };
        }
开发者ID:Rumel,项目名称:Radabite,代码行数:36,代码来源:FooSimplex.cs


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