private void InsertAttributeValue(SqlInsertQuery query, List <Object> attributes, int randomVariable)
        {
            underlineDatabase.InsertValueIntoAttributeTable(query.TableName + "_0", randomVariable, 1, "TupleExistence", query.TupleP);

            for (int i = 1; i <= attributes.Count; i++)
            {
                string attributeTableName = query.TableName + "_" + i;

                var value = attributes[i - 1] as DeterministicAttribute;
                if (value != null)
                {
                    DeterministicAttribute attribute = value;
                    double prob = 0;
                    prob = 100;
                    underlineDatabase.InsertValueIntoAttributeTable(attributeTableName, randomVariable, 1, attribute.AttributeValue1, prob);
                }
                else
                {
                    var probabilisticAttribute = attributes[i - 1] as ProbabilisticSingleAttribute;
                    if (probabilisticAttribute != null)
                    {
                        var           attribute = probabilisticAttribute;
                        List <String> v         = attribute.Values;
                        List <double> p         = attribute.Probs;

                        for (int j = 0; j < v.Count; j++)
                        {
                            // attribute value starting from 1 upto number of possible values,
                            // because 0 is system reserve for null state.
                            underlineDatabase.InsertValueIntoAttributeTable(attributeTableName, randomVariable, j + 1, v[j], p[j]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void InsertAttributeValue(string tableName, List <object> attributes, int randomVariable, List <string> tNames)
        {
            var tableJoins = string.Join(",", tNames);

            underlineDatabase.InsertValueIntoAttributeTable(tableName + "_0", randomVariable, 1, tableJoins, query.TupleP);

            for (int i = 1; i <= attributes.Count; i++)
            {
                var attObj = attributes[i - 1];
                if (attObj is DeterministicAttribute)
                {
                    var          attribute = attObj as DeterministicAttribute;
                    const double prob      = 100;

                    underlineDatabase.InsertValueIntoAttributeTable(tNames[i - 1], randomVariable, 1, attribute.AttributeValue1, prob);
                }
                else if (attObj is ProbabilisticSingleAttribute)
                {
                    var           attribute = attObj as ProbabilisticSingleAttribute;
                    List <String> v         = attribute.Values;
                    List <double> p         = attribute.Probs;

                    for (int j = 0; j < v.Count; j++)
                    {
                        // attribute value starting from 1 upto number of possible values,
                        // because 0 is system reserve for null state.
                        underlineDatabase.InsertValueIntoAttributeTable(tNames[i - 1], randomVariable, j + 1, v[j], p[j]);
                    }
                }
                else if (attObj is ProbabilisticMultiAttribute)
                {
                    var pAttributes = attObj as ProbabilisticMultiAttribute;
                    var vs          = pAttributes.MultiAttrbutes;
                    var p           = pAttributes.PValues;

                    for (int j = 0; j < vs.Count; j++)
                    {
                        underlineDatabase.InsertValueIntoAttributeTable(tNames[i - 1], randomVariable, j + 1, vs[j], p[j]);
                    }
                }
                else
                {
                    throw new Exception("attribute object invalid");
                }
            }
        }