这是我想作为约束添加到 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);