本文整理汇总了C#中IVariable.Operation方法的典型用法代码示例。如果您正苦于以下问题:C# IVariable.Operation方法的具体用法?C# IVariable.Operation怎么用?C# IVariable.Operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVariable
的用法示例。
在下文中一共展示了IVariable.Operation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
public IVariable Set(IMilpManager milpManager, CompositeConstraintType type, ICompositeConstraintParameters parameters,
IVariable leftVariable, params IVariable[] rightVariable)
{
leftVariable.Operation(OperationType.DifferentValuesCount, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(rightVariable.Length + 1));
return leftVariable;
}
示例2: Set
public IVariable Set(IMilpManager milpManager, CompositeConstraintType type, ICompositeConstraintParameters parameters,
IVariable leftVariable, params IVariable[] rightVariable)
{
rightVariable.Aggregate(milpManager.FromConstant(0),
(current, variable) =>
current.Operation(OperationType.Addition, leftVariable.Operation(OperationType.IsEqual, variable))).Create()
.Set(ConstraintType.Equal, milpManager.FromConstant(0));
return leftVariable;
}
示例3: CalculatePower
private static IVariable CalculatePower(IVariable number, IVariable power, IMilpManager milpManager, IVariable isEdgeCase)
{
var digits = (int)Math.Ceiling(Math.Log(milpManager.IntegerWidth, 2.0));
var infinity = milpManager.FromConstant(milpManager.MaximumIntegerValue);
var currentPower = milpManager.Operation(OperationType.Minimum, number, isEdgeCase.Operation(OperationType.BinaryNegation).Operation(OperationType.Multiplication, infinity));
var decomposition = power.CompositeOperation(CompositeOperationType.UnsignedMagnitudeDecomposition).Take(digits).ToArray();
var one = milpManager.FromConstant(1);
var result = one;
for (int i = 0; i < digits; ++i)
{
if (i > 0)
{
var isAnyNonzeroDigitLater = milpManager.Operation(OperationType.Disjunction, decomposition.Skip(i).ToArray());
var numberToMultiply = milpManager.Operation(OperationType.Minimum, currentPower, isAnyNonzeroDigitLater.Operation(OperationType.Multiplication, infinity));
currentPower = numberToMultiply.Operation(OperationType.Multiplication, numberToMultiply);
}
result = result.Operation(OperationType.Multiplication, one.Operation(OperationType.Maximum, currentPower.Operation(OperationType.Multiplication, decomposition[i])));
}
return result;
}
示例4: MakePositiveIfNeeded
private static IVariable MakePositiveIfNeeded(IVariable variable)
{
if (variable.Domain == Domain.AnyInteger || variable.Domain == Domain.AnyConstantInteger)
{
variable = variable.Operation(OperationType.AbsoluteValue);
}
return variable;
}
示例5: MultipleByBinaryDigit
private IVariable MultipleByBinaryDigit(IMilpManager baseMilpManager, IVariable number, IVariable digit)
{
if (number.Domain == Domain.AnyConstantInteger || number.Domain == Domain.AnyInteger)
{
var absoluteNumber = number.Operation(OperationType.AbsoluteValue);
var result = MultipleByBinaryDigit(baseMilpManager, absoluteNumber, digit);
var two = baseMilpManager.FromConstant(2);
return MultipleByBinaryDigit(baseMilpManager, result, number.Operation(OperationType.IsGreaterOrEqual, baseMilpManager.FromConstant(0)))
.Operation(OperationType.Subtraction,
result.Operation(OperationType.Division, two))
.Operation(OperationType.Multiplication, two);
}
IVariable digitMultipliedByInfinity = digit.Operation(OperationType.Multiplication, baseMilpManager.FromConstant(baseMilpManager.MaximumIntegerValue));
return baseMilpManager.Operation(OperationType.Minimum,
number,
digitMultipliedByInfinity
);
}
示例6: FixSign
private IVariable FixSign(IMilpManager baseMilpManager, IVariable[] nonBinaries, bool mightBeNegatives, IVariable zero,
IVariable result)
{
if (mightBeNegatives)
{
var sign =
nonBinaries[0].Operation(OperationType.IsGreaterOrEqual, zero)
.Operation(OperationType.IsEqual,
nonBinaries[1].Operation(OperationType.IsGreaterOrEqual, zero));
var two = baseMilpManager.FromConstant(2);
result =
MultipleByBinaryDigit(baseMilpManager, result, sign)
.Operation(OperationType.Subtraction,
result.Operation(OperationType.Division, two))
.Operation(OperationType.Multiplication, two);
}
return result;
}