本文整理汇总了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()
};
}