微软求解器基础约束逻辑错误

时间:2014-02-27 17:53:30

标签: c# ms-solver-foundation

这是我想要作为约束添加到Microsoft求解器基础的公式。

我在此代码中使用 SumTermBuilder 类,但解算器给出了错误的结果,此代码没有编译错误。为什么我得错了结果?

代码:

var N_Available_Total = new SumTermBuilder(decisions.Count());
var OM_Available_Total = new SumTermBuilder(decisions.Count());
var Hourly = new SumTermBuilder(96);
for (int i = 1; i < 97; i++)
{
    foreach (var item in newfeed)
    {
        float x = item.N_ED_Available_at_time_Total[i]/100;
        float y = item.OM_ED_Available_at_time_Total[i]/100;
        //get decision variables list
        var feeddecision = model.Decisions.First(it => it.Name == item.feed);
        //summation of all decision variables 
        N_Available_Total.Add(feeddecision * x); // For N
        OM_Available_Total.Add(feeddecision * y); // for OM
    }
    Hourly.Add((Model.Sqrt(Model.Power((25 - ((N_Available_Total.ToTerm() / OM_Available_Total.ToTerm()))), 2)))/96);
}
var SIConstraint = (25 - ((Hourly.ToTerm())) / 25) >= 0.9;
model.AddConstraint("SI", SIConstraint);

0 个答案:

没有答案