• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Cream.Variable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Cream.Variable的典型用法代码示例。如果您正苦于以下问题:C# Variable类的具体用法?C# Variable怎么用?C# Variable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Variable类属于Cream命名空间,在下文中一共展示了Variable类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Relation

 public Relation(Network net, Variable v0, bool[][] rel, Variable v1, ConstraintTypes cType, int weight)
     : base(net, cType, weight)
 {
     _rel = rel;
     _v0 = v0;
     _v1 = v1;
 }
开发者ID:kikoanis,项目名称:CSharpCream,代码行数:7,代码来源:Relation.cs


示例2: Element

 public Element(Network net, Variable v0, Variable v1, Variable[] v, ConstraintTypes cType, int weight)
     : base(net, cType, weight)
 {
     _v0 = v0;
     _v1 = v1;
     _v = (Variable[])v.Clone();
 }
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:7,代码来源:Element.cs


示例3: Sequential

 public Sequential(Network net, Variable[] v, int[] l, ConstraintTypes cType, int weight)
     : base(net, cType, weight)
 {
     _v = new Variable[v.Length];
     v.CopyTo(_v, 0);
     _l = new int[l.Length];
     l.CopyTo(_l, 0);
 }
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:8,代码来源:Sequential.cs


示例4: IntArith

 private IntArith(Network net, int a, Variable[] v, ConstraintTypes cType = ConstraintTypes.Hard)
     : this(net, a, v, cType, 0)
 {
 }
开发者ID:kikoanis,项目名称:CSharpCream,代码行数:4,代码来源:IntArith.cs


示例5: IntComparison

 public IntComparison(Network net, int comp, Variable v0, int x1)
     : this(net, comp, v0, new IntVariable(net, x1))
 {
 }
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:4,代码来源:IntComparison.cs


示例6: SatisfyLT

 private static bool SatisfyLT(Variable v0, Variable v1, Trail trail)
 {
     var d0 = (IntDomain)v0.Domain;
     var d1 = (IntDomain)v1.Domain;
     d0 = d0.CapInterval(IntDomain.MinValue, d1.Maximum() - 1);
     if (d0.Empty)
         return false;
     if (trail != null)
     {
         v0.UpdateDomain(d0, trail);
     }
     d1 = d1.CapInterval(d0.Minimum() + 1, IntDomain.MaxValue);
     if (d1.Empty)
         return false;
     if (trail != null)
     {
         v1.UpdateDomain(d1, trail);
     }
     return true;
 }
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:20,代码来源:IntComparison.cs


示例7: VariableToken

 public VariableToken(Variable value)
 {
     _value = value;
 }
开发者ID:samplet,项目名称:CreamCheese,代码行数:4,代码来源:VariableToken.cs


示例8: NotEquals

 public NotEquals(Network net, Variable[] va, ConstraintTypes cType, int weight)
     : base(net, cType, weight)
 {
     _v = new Variable[va.Length];
     va.CopyTo(_v, 0);
 }
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:6,代码来源:NotEquals.cs


示例9: SatisfyAdd

        private static bool SatisfyAdd(Variable v0, Variable v1, Variable v2, Trail trail)
        {
            var d0 = (IntDomain) v0.Domain;
            var d1 = (IntDomain) v1.Domain;
            var d2 = (IntDomain) v2.Domain;

            if (d1.Size() == 1 && d2.Size() == 1)
            {
                // v0 = v1 + v2
                var value = d1.Value() + d2.Value();
                if (!d0.Contains(value))
                    return false;
                if (d0.Size() > 1)
                    if (trail != null)
                    {
                        v0.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }
            if (d0.Size() == 1 && d2.Size() == 1)
            {
                // v1 = v0 - v2
                var value = d0.Value() - d2.Value();
                if (!d1.Contains(value))
                    return false;
                if (d1.Size() > 1)
                    if (trail != null)
                    {
                        v1.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }
            if (d0.Size() == 1 && d1.Size() == 1)
            {
                // v2 = v0 - v1
                var value = d0.Value() - d1.Value();
                if (!d2.Contains(value))
                    return false;
                if (d2.Size() > 1)
                    if (trail != null)
                    {
                        v2.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }

            // v0 = v1 + v2
            d0 = d0.CapInterval(d1.Minimum() + d2.Minimum(), d1.Maximum() + d2.Maximum());
            if (d0.Empty)
                return false;
            if (trail != null)
            {
                v0.UpdateDomain(d0, trail);
            }
            // v1 = v0 - v2
            d1 = d1.CapInterval(d0.Minimum() - d2.Maximum(), d0.Maximum() - d2.Minimum());
            if (d1.Empty)
                return false;
            if (trail != null)
            {
                v1.UpdateDomain(d1, trail);
            }
            // v2 = v0 - v1
            d2 = d2.CapInterval(d0.Minimum() - d1.Maximum(), d0.Maximum() - d1.Minimum());
            if (d2.Empty)
                return false;
            if (trail != null)
            {
                v2.UpdateDomain(d2, trail);
            }

            return true;
        }
开发者ID:kikoanis,项目名称:CSharpCream,代码行数:73,代码来源:IntArith.cs


示例10: SatisfyMIN

        private static bool SatisfyMIN(Variable v0, Variable v1, Variable v2, Trail trail)
        {
            var d0 = (IntDomain) v0.Domain;
            var d1 = (IntDomain) v1.Domain;
            var d2 = (IntDomain) v2.Domain;

            if (d1.Size() == 1 && d2.Size() == 1)
            {
                // v0 = Min(v1, v2)
                int value = Math.Min(d1.Value(), d2.Value());
                if (!d0.Contains(value))
                    return false;
                if (d0.Size() > 1)
                    if (trail != null)
                    {
                        v0.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }
            if (d0.Size() == 1)
            {
                int value = d0.Value();
                if (!d1.Contains(value) && !d2.Contains(value))
                    return false;
                // ???
                if (d1.Minimum() < value)
                {
                    d1.CapInterval(value, IntDomain.MaxValue);
                    if (d1.Empty)
                        return false;
                    if (trail != null)
                    {
                        v1.UpdateDomain(d1, trail);
                    }
                }
                if (d2.Minimum() < value)
                {
                    d2.CapInterval(value, IntDomain.MaxValue);
                    if (d2.Empty)
                        return false;
                    if (trail != null)
                    {
                        v2.UpdateDomain(d2, trail);
                    }
                }
                return true;
            }

            // v0 = Min(v1, v2)
            int min = Math.Min(d1.Minimum(), d2.Minimum());
            int max = Math.Min(d1.Maximum(), d2.Maximum());
            d0 = d0.CapInterval(min, max);
            if (d0.Empty)
                return false;
            if (trail != null)
            {
                v0.UpdateDomain(d0, trail);
            }
            //
            if (d1.Minimum() < d0.Minimum())
                d1 = d1.CapInterval(d0.Minimum(), IntDomain.MaxValue);
            if (d2.Minimum() < d0.Minimum())
                d2 = d2.CapInterval(d0.Minimum(), IntDomain.MaxValue);
            if (d1.Minimum() > d0.Maximum())
            {
                d0 = (IntDomain) d0.Cap(d2);
                d2 = d0;
            }
            if (d2.Minimum() > d0.Maximum())
            {
                d0 = (IntDomain) d0.Cap(d1);
                d1 = d0;
            }
            if (d0.Empty)
                return false;
            if (d1.Empty)
                return false;
            if (d2.Empty)
                return false;
            if (trail != null)
            {
                v0.UpdateDomain(d0, trail);
                v1.UpdateDomain(d1, trail);
                v2.UpdateDomain(d2, trail);
            }
            return true;
        }
开发者ID:kikoanis,项目名称:CSharpCream,代码行数:87,代码来源:IntArith.cs


示例11: SatisfyMULTIPLY

        private static bool SatisfyMULTIPLY(Variable v0, Variable v1, Variable v2, Trail trail)
        {
            var d0 = (IntDomain) v0.Domain;
            var d1 = (IntDomain) v1.Domain;
            var d2 = (IntDomain) v2.Domain;

            if (d1.Size() == 1 && d2.Size() == 1)
            {
                // v0 = v1 * v2
                int value = ToInt(d1.Value() * (long) d2.Value());
                if (!d0.Contains(value))
                    return false;
                if (d0.Size() > 1)
                    if (trail != null)
                    {
                        v0.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }
            if (d0.Size() == 1 && d2.Size() == 1)
            {
                // v1 = v0 / v2
                int x = d0.Value();
                int y = d2.Value();
                if (y == 0)
                {
                    return x == 0;
                }
                if (x % y != 0)
                {
                    return false;
                }
                int value = x / y;
                if (!d1.Contains(value))
                    return false;
                if (d1.Size() > 1)
                    if (trail != null)
                    {
                        v1.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }
            if (d0.Size() == 1 && d1.Size() == 1)
            {
                // v2 = v0 / v1
                int x = d0.Value();
                int y = d1.Value();
                if (y == 0)
                {
                    return x == 0;
                }
                if (x % y != 0)
                {
                    return false;
                }
                int value = x / y;
                if (!d2.Contains(value))
                    return false;
                if (d2.Size() > 1)
                    if (trail != null)
                    {
                        v2.UpdateDomain(new IntDomain(value), trail);
                    }
                return true;
            }

            d0 = Multiply(d0, d1, d2);
            if (d0.Empty)
                return false;
            d1 = Divide(d1, d0, d2);
            if (d1.Empty)
                return false;
            d2 = Divide(d2, d0, d1);
            if (d2.Empty)
                return false;
            if (trail != null)
            {
                if (d0 != v0.Domain)
                    v0.UpdateDomain(d0, trail);
                if (d1 != v1.Domain)
                    v1.UpdateDomain(d1, trail);
                if (d2 != v2.Domain)
                    v2.UpdateDomain(d2, trail);
            }
            return true;
        }
开发者ID:kikoanis,项目名称:CSharpCream,代码行数:86,代码来源:IntArith.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Docking.Content类代码示例发布时间:2022-05-24
下一篇:
C# Cream.Network类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap