Exemplo n.º 1
0
        public int FindIneqIndex(ListHyp hypermap, Label ineqId)
        {
            try
            {
                if (!constraints.ContainsKey(ineqId.name))
                {
                    throw new Exception("Constraint " + ineqId.name + " is not defined in 000.txt");
                }

                Definition      c       = constraints[ineqId.name];
                HypermapElement element = hypermap.Translate(c.domain, ineqId.index);
                if (element == null)
                {
                    throw new Exception(
                              String.Format("Element with the index {0} is not found for the domain {1}", ineqId.index, c.domain));
                }

                return(hypermap.FindElementIndex(c.set, element));
            }
            catch (Exception e)
            {
                throw new Exception(
                          String.Format("Inequality {0} problem: {1}", ineqId.name, e.Message));
            }
        }
Exemplo n.º 2
0
        public int FindIneqIndex(ListHyp hypermap, Label ineqId)
        {
            Definition      c       = constraints[ineqId.name];
            HypermapElement element = hypermap.Translate(c.domain, ineqId.index);

            return(hypermap.FindElementIndex(c.set, element));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Changes the index of the variable
        /// </summary>
        /// <param name="hypermap"></param>
        public void Relabel(ListHyp hypermap)
        {
            // No index
            if (Name.index == "")
            {
                return;
            }

            HypermapElement element = hypermap.Manager.TranslateVariable(hypermap, Name);

            Name = new Label(Name.name, element.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Finds the index of the given element in the specific set
        /// </summary>
        /// <param name="setName"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public int FindElementIndex(string setName, HypermapElement element)
        {
            var set   = sets[setName];
            int index = set.IndexOf(element);

            if (index < 0)
            {
                throw new Exception(String.Format("Element {0} is not found in set {1}", element, setName));
            }

            return(index);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Prints the given inequality into a stream
        /// </summary>
        private void WriteIneqText(Inequality ineq, LpNumber marginal, int precision,
                                   StreamWriter writer, ListHyp hypermap)
        {
            // Relabel
            HypermapElement element = hypermap.Manager.TranslateIneq(hypermap, ineq.Id);
            int             index   = hypermap.Manager.FindIneqIndex(hypermap, ineq.Id);

            // Write out
            if (ineq.NegFlag && ineq.type == Inequality.IneqType.Eq)
            {
                writer.Write("-");
            }
            writer.Write(ineq.Id + " & ");
            writer.Write(index + " & ");
            writer.Write(element + ": ");
            writer.Write(ineq.ToHOLString(precision, vars));
            writer.Write("\t (");
            writer.Write(marginal.ToHOLString(precision));
            writer.WriteLine(")");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Finds the index of the given element in the specific set
        /// </summary>
        /// <param name="setName"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public int FindElementIndex(string setName, HypermapElement element)
        {
            var set = sets[setName];
            int index = set.IndexOf(element);

            if (index < 0)
            {
                throw new Exception(String.Format("Element {0} is not found in set {1}", element, setName));
            }

            return index;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Finds the index of the given element in the specific set
        /// </summary>
        /// <param name="setName"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public int FindElementIndex(string setName, HypermapElement element)
        {
            var set = sets[setName];

            return(set.IndexOf(element));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Finds the index of the given element in the specific set
 /// </summary>
 /// <param name="setName"></param>
 /// <param name="element"></param>
 /// <returns></returns>
 public int FindElementIndex(string setName, HypermapElement element)
 {
     var set = sets[setName];
     return set.IndexOf(element);
 }