/// <summary>
        /// The point here is to allow us to save a copy of the model with a current set of factors and metadata mappings,
        /// which can come in super handy with gameplaying applications.
        /// </summary>
        /// <remarks>
        /// The point here is to allow us to save a copy of the model with a current set of factors and metadata mappings,
        /// which can come in super handy with gameplaying applications. The cloned model doesn't instantiate the feature
        /// thunks inside factors, those are just taken over individually.
        /// </remarks>
        /// <returns>a clone</returns>
        public virtual GraphicalModel CloneModel()
        {
            GraphicalModel clone = new GraphicalModel();

            clone.modelMetaData.PutAll(modelMetaData);
            for (int i = 0; i < variableMetaData.Count; i++)
            {
                if (variableMetaData[i] != null)
                {
                    clone.GetVariableMetaDataByReference(i).PutAll(variableMetaData[i]);
                }
            }
            foreach (GraphicalModel.Factor f in factors)
            {
                clone.factors.Add(f.CloneFactor());
            }
            return(clone);
        }