我在我的程序中使用Microsoft Solver Foundation Express
eddition,Express版本根据this link限制在模型大小中。我在Solver Foundation模型中定义了多少个术语/变量/约束/非零?
有没有办法找到多少:
- 条款
- 变量
- 约束
- 非零
我在模型中定义,使用代码?
我在我的程序中使用Microsoft Solver Foundation Express
eddition,Express版本根据this link限制在模型大小中。我在Solver Foundation模型中定义了多少个术语/变量/约束/非零?
有没有办法找到多少:
我在模型中定义,使用代码?
Model类将Decisions
和Constraints
作为集合维护。你可以列举这些并计数它们。
要跟踪您的Term
变量,您可以使用自己的构造方法创建并计数它们。
例子:
static Term NewTerm(Term t)
{
noOfTerms++; // defined as class variable somewhere else
return t;
}
static void Main(string[] args)
{
var context = SolverContext.GetContext();
var model = context.CreateModel();
double sqrt2 = Math.Sqrt(2.0);
var t = new Decision(Domain.RealRange(-sqrt2, +sqrt2), "t");
var u = new Decision(Domain.RealRange(-2 * sqrt2, +2 * sqrt2), "u");
model.AddDecisions(t, u);
Term P = NewTerm(2 * t * t/(3 * t * t + u * u + 2 * t) - (u * u + t * t)/18);
model.AddGoal("objective", GoalKind.Maximize, P);
Console.WriteLine("Constraints: " + model.Constraints.Count());
Console.WriteLine("Decisions: " + model.Decisions.Count());
Console.WriteLine("Goals: " + model.Goals.Count());
Console.WriteLine("Terms: " + noOfTerms);
Solution sol = context.Solve();
Report report = sol.GetReport();
Console.WriteLine(report);
Console.WriteLine();
}
你可能知道,微软也不再积极推进微软求解基金会。
@Backs:你觉得我的问题是什么? – Masoud
@Backs:对我来说,这是一个完全有效的编程问题。 –