当前位置: 首页>>代码示例>>C#>>正文


C# IVariable.Operation方法代码示例

本文整理汇总了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;
        }
开发者ID:afish,项目名称:MilpManager,代码行数:8,代码来源:AllDifferentCalculator.cs

示例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;
        }
开发者ID:afish,项目名称:MilpManager,代码行数:10,代码来源:NotFromSetCalculator.cs

示例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;
        }
开发者ID:afish,项目名称:MilpManager,代码行数:24,代码来源:ExponentiationCalculator.cs

示例4: MakePositiveIfNeeded

        private static IVariable MakePositiveIfNeeded(IVariable variable)
        {
            if (variable.Domain == Domain.AnyInteger || variable.Domain == Domain.AnyConstantInteger)
            {
                variable = variable.Operation(OperationType.AbsoluteValue);
            }

            return variable;
        }
开发者ID:afish,项目名称:MilpManager,代码行数:9,代码来源:MultiplicationCalculator.cs

示例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
                );
        }
开发者ID:afish,项目名称:MilpManager,代码行数:19,代码来源:MultiplicationCalculator.cs

示例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;
 }
开发者ID:afish,项目名称:MilpManager,代码行数:18,代码来源:MultiplicationCalculator.cs


注:本文中的IVariable.Operation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。