Beispiel #1
0
        public TmsManager(StructuralReasonerOptions structuralReasonerOptions, Log log)
        {
            this.structuralReasonerOptions = structuralReasonerOptions;
            this.log = log;

            cdaStarTms = new Workspace();

            CreateDomains();
            CreateConstraintTypes();
        }
        /// <summary>
        /// Creates a TMS constraint
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="cdaStarTms">The CS3 instance where to create the constraint</param>
        /// <param name="variablesMap">A map for finding CS3 variables by name</param>
        /// <param name="constraintTypesMap">A map for finding CS3 constraint types by name</param>
        /// <returns></returns>
        public static IConstraint CreateIConstraint(this TmsConstraint constraint, ICDAStar cdaStarTms, Dictionary <string, IVariable> variablesMap, Dictionary <string, IConstraintType> constraintTypesMap)
        {
            IVariable[] variables = new IVariable[constraint.VariableTuple.Count];

            for (int i = 0; i < constraint.VariableTuple.Count; i++)
            {
                variables[i] = variablesMap[constraint.VariableTuple[i]];
            }

            return(cdaStarTms.DefConstraint(constraintTypesMap[constraint.ConstraintType], variables));
        }
        /// <summary>
        /// Creates a TMS constraint type out of the current constraint type
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="cdaStarTms">The CS3 instance where to create the constraint type</param>
        /// <param name="domainsMap">A map from the SR domains to the CS3 domains</param>
        /// <returns></returns>
        public static IConstraintType CreateIConstraintType(this GKOConstraintType ct, ICDAStar cdaStarTms, Dictionary <string, IDomain> domainsMap)
        {
            IDomain[]  signature = new IDomain[ct.Signature.Count];
            string[][] tuples    = new string[ct.Tuples.Count][];

            for (int i = 0; i < ct.Signature.Count; i++)
            {
                signature[i] = domainsMap[ct.Signature[i].Name];
            }

            for (int i = 0; i < ct.Tuples.Count; i++)
            {
                tuples[i] = ct.Tuples[i].ToArray();
            }

            return(cdaStarTms.DefConstraintType(ct.Name, signature, tuples));
        }
 /// <summary>
 /// Creates a TMS variable
 /// </summary>
 /// <param name="variable"></param>
 /// <param name="cdaStarTms">The CS3 instance where to create the variable</param>
 /// <param name="domainsMap">A map from the SR domains to the CS3 domains</param>
 /// <returns></returns>
 public static IVariable CreateIVariable(this TmsDecisionVariable variable, ICDAStar cdaStarTms, Dictionary <string, IDomain> domainsMap)
 {
     return(cdaStarTms.DefVariable(variable.Name, domainsMap[variable.Domain.Id]));
 }
 /// <summary>
 /// Creates a TMS domain out of the current domain
 /// </summary>
 /// <param name="domain"></param>
 /// <param name="cdaStarTms">The CS3 instance where to create the domain</param>
 /// <returns></returns>
 public static IDomain CreateIDomain(this GKODomainAbstract domain, ICDAStar cdaStarTms)
 {
     return(cdaStarTms.DefDomain(domain.Name, domain.GetValues().ToArray()));
 }