本文整理汇总了C#中IVariable类的典型用法代码示例。如果您正苦于以下问题:C# IVariable类的具体用法?C# IVariable怎么用?C# IVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVariable类属于命名空间,在下文中一共展示了IVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertInListChange
/// <summary>
/// Constructor
/// </summary>
/// <param name="context"></param>
/// <param name="statement"></param>
/// <param name="variable"></param>
/// <param name="explanation"></param>
public InsertInListChange(InterpretationContext context, InsertStatement statement, IVariable variable, ExplanationPart explanation)
: base(variable, null, null)
{
Context = context;
Statement = statement;
Explanation = explanation;
}
示例2: CalculateDomain
private static Domain CalculateDomain(IVariable[] arguments)
{
if (arguments.All(a => a.IsBinary()))
{
return Domain.BinaryInteger;
}
if (IsDividingByConstant(arguments))
{
if (arguments.All(a => a.IsInteger()))
{
if (arguments.All(a => a.IsPositiveOrZero() || a.IsBinary()))
{
return Domain.PositiveOrZeroInteger;
}
return Domain.AnyInteger;
}
else
{
if (arguments.All(a => a.IsPositiveOrZero() || a.IsBinary()))
{
return Domain.PositiveOrZeroReal;
}
return Domain.AnyReal;
}
}
if (arguments.All(a => a.IsPositiveOrZero() || a.IsBinary()))
{
return Domain.PositiveOrZeroInteger;
}
return Domain.AnyInteger;
}
示例3: Set
public IVariable Set(IMilpManager milpManager, ConstraintType type, IVariable leftVariable, IVariable rightVariable)
{
IVariable any = milpManager.CreateAnonymous(Domain.AnyInteger);
leftVariable.Set(ConstraintType.Equal,any.Operation(OperationType.Multiplication, rightVariable));
return leftVariable;
}
示例4: VariableStartEntry
/// <summary>
/// Default ctor
/// </summary>
public VariableStartEntry(int offset, Register register, IVariable variable, TypeReference type) : base(offset)
{
this.register = register;
Variable = variable;
name = variable.OriginalName;
this.type = type;
}
示例5: GetStatus
public VariableState GetStatus (IVariable variable)
{
VariableState state;
if (!states.TryGetValue (variable, out state))
return VariableState.None;
return state;
}
示例6: Set
public IVariable Set(IMilpManager milpManager, ConstraintType type, IVariable leftVariable,
IVariable rightVariable)
{
switch (type)
{
case ConstraintType.Equal:
milpManager.SetEqual(leftVariable, rightVariable);
leftVariable.ConstantValue = rightVariable.ConstantValue ?? leftVariable.ConstantValue;
rightVariable.ConstantValue = leftVariable.ConstantValue ?? rightVariable.ConstantValue;
break;
case ConstraintType.LessOrEqual:
milpManager.SetLessOrEqual(leftVariable, rightVariable);
break;
case ConstraintType.GreaterOrEqual:
milpManager.SetGreaterOrEqual(leftVariable, rightVariable);
break;
case ConstraintType.LessThan:
milpManager.Operation(OperationType.IsLessThan, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
case ConstraintType.GreaterThan:
milpManager.Operation(OperationType.IsGreaterThan, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
case ConstraintType.NotEqual:
milpManager.Operation(OperationType.IsNotEqual, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
default:
throw new InvalidOperationException("Cannot set constraint");
}
return leftVariable;
}
示例7: Change
/// <summary>
/// Constructor
/// </summary>
/// <param name="variable"></param>
/// <param name="previousValue"></param>
/// <param name="newValue"></param>
public Change(IVariable variable, IValue previousValue, IValue newValue)
{
Variable = variable;
PreviousValue = previousValue;
NewValue = newValue;
Applied = false;
}
示例8: AddVariable
private void AddVariable(IVariable v, bool isUsedByReference = false) {
string n = _namer.GetVariableName(v.Name, _usedNames);
_usedNames.Add(n);
_result.Add(v, new VariableData(n, _currentMethod, isUsedByReference));
if (_isInsideLoop)
_variablesDeclaredInsideLoop.Add(v);
}
示例9: VariableAggregationFilter
public VariableAggregationFilter(IVariable variable, [GreaterThan(0)]int stepSize, int minIndex, int maxIndex)
{
this.minIndex = minIndex;
this.maxIndex = maxIndex;
this.stepSize = stepSize;
this.variable = variable;
}
示例10: CalculateForVariable
private static IEnumerable<IVariable> CalculateForVariable(IMilpManager milpManager, IVariable[] arguments, uint decompositionBase)
{
List<Tuple<IVariable, int>> variables =
Enumerable.Range(0, GetDigitsCount(milpManager, decompositionBase))
.Select(i =>
{
var baseRaised = (int)Math.Pow(decompositionBase, i);
var variable = milpManager.CreateAnonymous(decompositionBase == 2 ? Domain.BinaryInteger : Domain.PositiveOrZeroInteger);
if (decompositionBase > 2)
{
variable = variable.Set(ConstraintType.LessOrEqual,milpManager.FromConstant((int) decompositionBase - 1));
}
return Tuple.Create(variable, baseRaised);
})
.ToList();
milpManager.Operation(OperationType.Addition,
variables.Select(v => v.Item1.Operation(OperationType.Multiplication, milpManager.FromConstant(v.Item2)))
.ToArray()).Set(ConstraintType.Equal, arguments[0]);
return variables.Select((v, index) => {
var result = v.Item1;
result.Expression = $"decomposition(digit: {index}, base: {decompositionBase}, {arguments[0].FullExpression()})";
return result;
});
}
示例11: ExpressionException
public ExpressionException(string message, int column, int length, IVariable variable)
: base(message)
{
m_column = column;
m_length = length;
m_variable = variable;
}
示例12: LocalResolveResult
public LocalResolveResult(IVariable variable, IType type, object constantValue = null)
: base(type)
{
if (variable == null)
throw new ArgumentNullException("variable");
this.variable = variable;
this.constantValue = constantValue;
}
示例13: DivideVariableByConstant
public override IVariable DivideVariableByConstant(IVariable variable, IVariable constant, Domain domain)
{
var newVariable = InternalDivideVariableByConstant(variable, constant, domain);
newVariable.Domain = domain;
newVariable.MilpManager = this;
Variables[newVariable.Name] = newVariable;
return newVariable;
}
示例14: CreateVariableItem
private ListViewItem CreateVariableItem(IVariable variable, IFrame frame)
{
var item = new ListViewItem(new string[4]);
item.Tag = variable;
item.UseItemStyleForSubItems = false;
UpdateVariableItem(item, frame);
return item;
}
示例15: AddParameter
private IParameter AddParameter(IVariable variable)
{
var parameter = Owner.CreateParameter("value", variable.Type);
Parameters.Add(parameter);
return parameter;
}