本文整理汇总了C#中Variable.Index方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.Index方法的具体用法?C# Variable.Index怎么用?C# Variable.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.Index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: nn_inf
// Models the cone of nonnegative polynomials on the real axis
public static void nn_inf(Model M, Variable x)
{
int m = (int)x.Size() - 1;
int n = (m/2); // degree of polynomial is 2*n
//assert(m == 2*n)
// Setup variables
Variable X = M.Variable(Domain.InPSDCone(n+1));
// x_i = Tr H(n, i) * X i=0,...,m
for (int i = 0; i < m+1; ++i)
M.Constraint( Expr.Sub(x.Index(i), Expr.Dot(Hankel(n,i,1.0),X)), Domain.EqualsTo(0.0));
}
示例2: nn_semiinf
// Models the cone of nonnegative polynomials on the semi-infinite interval [0,inf)
public static void nn_semiinf(Model M, Variable x)
{
int n = (int)x.Size()-1;
int n1 = n/2,
n2 = (n-1)/2;
// Setup variables
Variable X1 = M.Variable(Domain.InPSDCone(n1+1));
Variable X2 = M.Variable(Domain.InPSDCone(n2+1));
// x_i = Tr H(n1, i) * X1 + Tr H(n2,i-1) * X2, i=0,...,n
for (int i = 0; i < n+1; ++i)
M.Constraint( Expr.Sub(x.Index(i),
Expr.Add(Expr.Dot(Hankel(n1,i,1.0), X1),
Expr.Dot(Hankel(n2,i-1,1.0),X2))), Domain.EqualsTo(0.0) );
}
示例3: nn_finite
// Models the cone of nonnegative polynomials on the finite interval [a,b]
public static void nn_finite(Model M, Variable x, double a, double b)
{
//assert(a < b)
int m = (int)x.Size()-1;
int n = m/2;
if (m == 2*n)
{
Variable X1 = M.Variable(Domain.InPSDCone(n+1));
Variable X2 = M.Variable(Domain.InPSDCone(n));
// x_i = Tr H(n,i)*X1 + (a+b)*Tr H(n-1,i-1) * X2 - a*b*Tr H(n-1,i)*X2 - Tr H(n-1,i-2)*X2, i=0,...,m
for (int i = 0; i < m+1; ++i)
M.Constraint( Expr.Sub(x.Index(i),
Expr.Add(Expr.Sub(Expr.Dot(Hankel(n, i,1.0), X1), Expr.Dot(Hankel(n-1, i, a*b), X2)),
Expr.Sub(Expr.Dot(Hankel(n-1, i-1, a+b), X2), Expr.Dot(Hankel(n-1, i-2,1.0), X2)))),
Domain.EqualsTo(0.0) );
}
else
{
Variable X1 = M.Variable(Domain.InPSDCone(n+1));
Variable X2 = M.Variable(Domain.InPSDCone(n+1));
// x_i = Tr H(n,i-1)*X1 - a*Tr H(n,i)*X1 + b*Tr H(n,i)*X2 - Tr H(n,i-1)*X2, i=0,...,m
for (int i = 0; i < m+1; ++i)
M.Constraint( Expr.Sub(x.Index(i),
Expr.Add(Expr.Sub(Expr.Dot(Hankel(n, i-1,1.0), X1), Expr.Dot(Hankel(n, i, a), X1)),
Expr.Sub(Expr.Dot(Hankel(n, i, b), X2), Expr.Dot(Hankel(n, i-1,1.0), X2)))),
Domain.EqualsTo(0.0) );
}
}