コード例 #1
0
        /// <summary> Returns a Copy of this network.
        /// The new network has the same structure as the original network.
        /// </summary>
        /// <returns> a Copy of this network
        /// </returns>
        public virtual Object Clone()
        {
            var net = new Network();
            var vs  = variables.GetEnumerator();

            while (vs.MoveNext())
            {
                var      v  = (Variable)vs.Current;
                Variable v1 = v.Copy(net);
                if (v.Index != v1.Index)
                {
                    throw new ArgumentException();
                }
            }
            var cs = constraints.GetEnumerator();

            while (cs.MoveNext())
            {
                var        c  = (Constraint)cs.Current;
                Constraint c1 = c.Copy(net);
                if (c.Index != c1.Index)
                {
                    throw new ArgumentException();
                }
            }
            if (objective != null)
            {
                net.Objective = net.GetVariable(objective.Index);
            }
            return(net);
        }
コード例 #2
0
        protected internal static Variable[] Copy(Variable[] v0, Network net)
        {
            var v = new Variable[v0.Length];

            for (int i = 0; i < v0.Length; i++)
            {
                int j = v0[i].Index;
                v[i] = net.GetVariable(j);
            }
            return(v);
        }
コード例 #3
0
ファイル: Constraint.cs プロジェクト: samplet/HalfAndHalf
 protected internal static Variable[] Copy(Variable[] v0, Network net)
 {
     var v = new Variable[v0.Length];
     for (int i = 0; i < v0.Length; i++)
     {
         int j = v0[i].Index;
         v[i] = net.GetVariable(j);
     }
     return v;
 }
コード例 #4
0
ファイル: Constraint.cs プロジェクト: samplet/HalfAndHalf
 protected internal static Variable Copy(Variable v0, Network net)
 {
     int j = v0.Index;
     return net.GetVariable(j);
 }
コード例 #5
0
ファイル: Network.cs プロジェクト: samplet/HalfAndHalf
 /// <summary> Returns a Copy of this network.
 /// The new network has the same structure as the original network.
 /// </summary>
 /// <returns> a Copy of this network
 /// </returns>
 public virtual Object Clone()
 {
     var net = new Network();
     var vs = _variables.GetEnumerator();
     while (vs.MoveNext())
     {
         var v = (Variable) vs.Current;
         Variable v1 = v.Copy(net);
         if (v.Index != v1.Index)
             throw new ArgumentException();
     }
     var cs = _constraints.GetEnumerator();
     while (cs.MoveNext())
     {
         var c = (Constraint) cs.Current;
         Constraint c1 = c.Copy(net);
         if (c.Index != c1.Index)
             throw new ArgumentException();
     }
     if (_objective != null)
     {
         net.Objective = net.GetVariable(_objective.Index);
     }
     return net;
 }
コード例 #6
0
        protected internal static Variable Copy(Variable v0, Network net)
        {
            int j = v0.Index;

            return(net.GetVariable(j));
        }