public InitialRecord(string expression)
     : base(WorldDescriptionRecordType.Initially)
 {
     this.PossibleFluents = new List<Fluent[]>();
     this.logicExpression = ServiceLocator.Current.GetInstance<ILogicExpression>();
     this.Expression = expression;
 }
Пример #2
0
 public ImpossibleActionIfRecord(WorldAction worldAction, string ifExpression)
     : base(WorldDescriptionRecordType.ImpossibleActionIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance <ILogicExpression>();
     this.ifExpression    = ifExpression;
     this.worldAction     = worldAction;
 }
Пример #3
0
 /// <summary>
 /// Adds the elements of an array to the end of this LogicExpressionCollection.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the end of this LogicExpressionCollection.
 /// </param>
 public virtual void AddRange(ILogicExpression[] items)
 {
     foreach (ILogicExpression item in items)
     {
         this.List.Add(item);
     }
 }
 public ActionReleasesIfRecord(WorldAction worldAction, Fluent fluent, string ifExpression)
     : base(WorldDescriptionRecordType.ActionReleasesIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance<ILogicExpression>();
     this.ifExpression = ifExpression;
     this.worldAction = worldAction;
     this.fluent = fluent;
 }
Пример #5
0
 public ActionCausesIfRecord(WorldAction worldAction, string resultExpression, string ifExpression)
     : base(WorldDescriptionRecordType.ActionCausesIf)
 {
     this.logicExpression  = ServiceLocator.Current.GetInstance <ILogicExpression>();
     this.resultExpression = resultExpression;
     this.ifExpression     = ifExpression;
     this.worldAction      = worldAction;
 }
 public ActionCausesIfRecord(WorldAction worldAction, string resultExpression, string ifExpression)
     : base(WorldDescriptionRecordType.ActionCausesIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance<ILogicExpression>();
     this.resultExpression = resultExpression;
     this.ifExpression = ifExpression;
     this.worldAction = worldAction;
 }
Пример #7
0
 public ActionReleasesIfRecord(WorldAction worldAction, Fluent fluent, string ifExpression)
     : base(WorldDescriptionRecordType.ActionReleasesIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance <ILogicExpression>();
     this.ifExpression    = ifExpression;
     this.worldAction     = worldAction;
     this.fluent          = fluent;
 }
Пример #8
0
 public ActionInvokesAfterIfRecord(WorldAction worldAction, WorldAction result, int after, string ifExpression)
     : base(WorldDescriptionRecordType.ActionInvokesAfterIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance <ILogicExpression>();
     this.ifExpression    = ifExpression;
     this.worldAction     = worldAction;
     this.result          = result;
     this.after           = after;
 }
 public ActionInvokesAfterIfRecord(WorldAction worldAction, WorldAction result, int after, string ifExpression)
     : base(WorldDescriptionRecordType.ActionInvokesAfterIf)
 {
     this.logicExpression = ServiceLocator.Current.GetInstance<ILogicExpression>();
     this.ifExpression = ifExpression;
     this.worldAction = worldAction;
     this.result = result;
     this.after = after;
 }
Пример #10
0
        public Tree(int timeInf)
        {
            _logger          = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ILog>();
            _logicExpression = new SimpleLogicExpression();

            LastLevel    = new List <Vertex>();
            _allVertices = new List <Vertex>();

            _TInf = timeInf;
        }
Пример #11
0
        public Tree(int timeInf)
        {
            _logger = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<ILog>();
            _logicExpression = new SimpleLogicExpression();

            LastLevel = new List<Vertex>();
            _allVertices = new List<Vertex>();

            _TInf = timeInf;
        }
Пример #12
0
        /// <summary>
        /// Converts the logic expression to collection.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">The <paramref name="expression"/> variable is null.</exception>
        public IEnumerable<ILogicExpression> ConvertLogicExpressionToCollection(ILogicExpression expression)
        {
            if (expression == null)
                throw new ArgumentNullException("expression");

            List<ILogicExpression> collection = new List<ILogicExpression>();
            ConvertToColletion(expression, collection);

            return collection;
        }
 private bool ValidationGoodFluents(ILogicExpression expression)
 {
     string[] fluentNames = expression.GetFluentNames();
     foreach (string item in fluentNames)
     {
         if (!_fluents.Exists(x => x.Name == item))
         {
             return(false);
         }
     }
     return(true);
 }
 public void AddExpression(ILogicExpression logicExpression)
 {
     if (logicExpression != null)
     {
         if (!string.IsNullOrEmpty(logicExpression.ToString()) && !string.IsNullOrEmpty(_expression))
         {
             _expression = "(" + _expression + ") && (" + logicExpression + ")";
         }
         else if (!string.IsNullOrEmpty(logicExpression.ToString()))
         {
             _expression = logicExpression.ToString();
         }
     }
 }
 public void AddExpression(ILogicExpression logicExpression)
 {
     if (logicExpression != null)
     {
         if (!string.IsNullOrEmpty(logicExpression.ToString()) && !string.IsNullOrEmpty(_expression))
         {
             _expression = "(" + _expression + ") && (" + logicExpression + ")";
         }
         else if (!string.IsNullOrEmpty(logicExpression.ToString()))
         {
             _expression = logicExpression.ToString();
         }
     }
 }
Пример #16
0
        private List <State> CreateStatesBasedOnObservations(List <string> fluentNames, ScenarioDescription scenarioDescription, ref int time)
        {
            List <State> states = new List <State>();

            time = scenarioDescription.GetNextObservationTime(0);
            if (time == -1 || time > _TInf)
            {
                return(states);
            }

            ScenarioObservationRecord observation = scenarioDescription.GetObservationFromTime(time);

            if (observation == null)
            {
                _logger.Warn("Scenario has no observations!");
                State state = new State();
                state.AddFluents(fluentNames);
                states.Add(state);
            }
            else
            {
                _logicExpression = new SimpleLogicExpression(observation.Expr as SimpleLogicExpression);

                List <Fluent[]> possibleInitialValues = _logicExpression.CalculatePossibleFluents();
                foreach (var valuation in possibleInitialValues)
                {
                    State state = new State();
                    state.AddFluents(fluentNames);
                    foreach (var fluent in valuation)
                    {
                        try
                        {
                            state.Fluents.First(f => f.Name == fluent.Name).Value = fluent.Value;
                        }
                        catch (System.ArgumentNullException)
                        {
                            _logger.Error("Fluent " + fluent.Name + " doesn't exist!");
                        }
                    }
                    states.Add(state);
                }
            }

            return(states);
        }
 private bool ValidationExpression(ILogicExpression expression)
 {
     return ValidationGoodFluents(expression);
 }
Пример #18
0
 public SimpleLogicExpressionTest()
 {
     _expression = new SimpleLogicExpression();
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Equality"/> class.
 /// </summary>
 /// <param name="firstOperand">The first (left) operand.</param>
 /// <param name="secondOperand">The second (right) operand.</param>
 public Equality(ILogicExpression firstOperand, ILogicExpression secondOperand)
     : base(firstOperand, secondOperand)
 {
 }
 private bool ValidationExpression(ILogicExpression expression)
 {
     return(ValidationGoodFluents(expression));
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Assign"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 /// <param name="value">The value.</param>
 public Assign(Variable variable, ILogicExpression value)
 {
     this.variable = variable;
     this.value = value;
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the LogicExpressionCollection class, containing elements
 /// copied from an array.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the new LogicExpressionCollection.
 /// </param>
 public LogicExpressionCollection(ILogicExpression[] items)
 {
     this.AddRange(items);
 }
Пример #23
0
 /// <summary>
 /// Inserts an element into the LogicExpressionCollection at the specified index
 /// </summary>
 /// <param name="index">
 /// The index at which the LogicExpression is to be inserted.
 /// </param>
 /// <param name="value">
 /// The LogicExpression to insert.
 /// </param>
 public virtual void Insert(int index, ILogicExpression value)
 {
     this.List.Insert(index, value);
 }
Пример #24
0
 /// <summary>
 /// Determines whether a specfic LogicExpression value is in this LogicExpressionCollection.
 /// </summary>
 /// <param name="value">
 /// The LogicExpression value to locate in this LogicExpressionCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this LogicExpressionCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(ILogicExpression value)
 {
     return this.List.Contains(value);
 }
Пример #25
0
 public ExpressionTriggersActionRecord(WorldAction worldAction, string ifExpression)
     : base(WorldDescriptionRecordType.ExpressionTriggersAction)
 {
     this.logicExpression = new SimpleLogicExpression(ifExpression);
     this.worldAction     = worldAction;
 }
 public void addObservation(ILogicExpression expr, int time)
 {
     ScenarioObservationRecord OBS = new ScenarioObservationRecord(expr, time);
     observations.Add(OBS);
 }
Пример #27
0
 public Instruction(ILogicExpression logicExpression, VariableValueExpression target)
 {
     LogicExpression = logicExpression;
     Target          = target;
 }
 public InitialRecord(string expression) : base(WorldDescriptionRecordType.Initially)
 {
     this.PossibleFluents = new List <Fluent[]>();
     this.logicExpression = ServiceLocator.Current.GetInstance <ILogicExpression>();
     this.Expression      = expression;
 }
Пример #29
0
        private List<State> CreateStatesBasedOnObservations(List<string> fluentNames, ScenarioDescription scenarioDescription, ref int time)
        {
            List<State> states = new List<State>();

            time = scenarioDescription.GetNextObservationTime(0);
            if (time == -1 || time > _TInf)
            {
                return states;
            }

            ScenarioObservationRecord observation = scenarioDescription.GetObservationFromTime(time);
            if (observation == null)
            {
                _logger.Warn("Scenario has no observations!");
                State state = new State();
                state.AddFluents(fluentNames);
                states.Add(state);
            }
            else
            {
                _logicExpression = new SimpleLogicExpression(observation.Expr as SimpleLogicExpression);

                List<Fluent[]> possibleInitialValues = _logicExpression.CalculatePossibleFluents();
                foreach (var valuation in possibleInitialValues)
                {
                    State state = new State();
                    state.AddFluents(fluentNames);
                    foreach (var fluent in valuation)
                    {
                        try
                        {
                            state.Fluents.First(f => f.Name == fluent.Name).Value = fluent.Value;
                        }
                        catch (System.ArgumentNullException)
                        {
                            _logger.Error("Fluent " + fluent.Name + " doesn't exist!");
                        }

                    }
                    states.Add(state);
                }
            }

            return states;
        }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Implication"/> class.
 /// </summary>
 /// <param name="firstOperand">The first (left) operand.</param>
 /// <param name="secondOperand">The second (right) operand.</param>
 public Implication(ILogicExpression firstOperand, ILogicExpression secondOperand)
     : base(firstOperand, secondOperand)
 {
 }
 private bool ValidationGoodFluents(ILogicExpression expression)
 {
     string[] fluentNames = expression.GetFluentNames();
     foreach(string item in fluentNames)
     {
         if(!_fluents.Exists(x => x.Name == item))
             return false;
     }
     return true;
 }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BinaryLogicExpression"/> class.
 /// </summary>
 /// <param name="left">The first (left) operand.</param>
 /// <param name="right">The second (right) operand.</param>
 protected BinaryLogicExpression(ILogicExpression left, ILogicExpression right)
 {
     this.left = left;
     this.right = right;
 }
Пример #33
0
 public IfElseExpression(ILogicExpression condition, IExpression branch1, IExpression branch2)
 {
     _condition = condition;
     _branch1   = branch1;
     _branch2   = branch2;
 }
Пример #34
0
 /// <summary>
 /// Adds an instance of type LogicExpression to the end of this LogicExpressionCollection.
 /// </summary>
 /// <param name="value">
 /// The LogicExpression to be added to the end of this LogicExpressionCollection.
 /// </param>
 public virtual void Add(ILogicExpression value)
 {
     this.List.Add(value);
 }
Пример #35
0
 public NotExpression(ILogicExpression target)
 {
     _target = target;
 }
Пример #36
0
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this LogicExpressionCollection
 /// </summary>
 /// <param name="value">
 /// The LogicExpression value to locate in the LogicExpressionCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(ILogicExpression value)
 {
     return this.List.IndexOf(value);
 }
Пример #37
0
 public LogicWorkspaceItem(string strExp, ILogicExpression exp)
     : this(strExp, exp, null)
 {
 }
Пример #38
0
 /// <summary>
 /// Removes the first occurrence of a specific LogicExpression from this LogicExpressionCollection.
 /// </summary>
 /// <param name="value">
 /// The LogicExpression value to remove from this LogicExpressionCollection.
 /// </param>
 public virtual void Remove(ILogicExpression value)
 {
     this.List.Remove(value);
 }
Пример #39
0
        public void addObservation(ILogicExpression expr, int time)
        {
            ScenarioObservationRecord OBS = new ScenarioObservationRecord(expr, time);

            observations.Add(OBS);
        }
Пример #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NAnd"/> class.
 /// </summary>
 /// <param name="firstOperand">The first (left) operand.</param>
 /// <param name="secondOperand">The second (right) operand.</param>
 public NAnd(ILogicExpression firstOperand, ILogicExpression secondOperand)
     : base(firstOperand, secondOperand)
 {
 }
 public ExpressionTriggersActionRecord(WorldAction worldAction, string ifExpression)
     : base(WorldDescriptionRecordType.ExpressionTriggersAction)
 {
     this.logicExpression = new SimpleLogicExpression(ifExpression);
     this.worldAction = worldAction;
 }
Пример #42
0
 public IfExpression(ILogicExpression condition, IExpression branch)
 {
     _condition = condition;
     _branch    = branch;
 }
Пример #43
0
 public WhileExpression(ILogicExpression condition, IExpression entry)
 {
     _condition = condition;
     _entry     = entry;
 }
 public ScenarioObservationRecord(ILogicExpression expr, int time)
     : base()
 {
     Expr = expr;
     Time = time;
 }
Пример #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Not"/> class.
 /// </summary>
 /// <param name="firstMathExpression">The expression.</param>
 public Not(ILogicExpression firstMathExpression)
     : base(firstMathExpression)
 {
 }
Пример #46
0
 public LogicWorkspaceItem(string strExp, ILogicExpression exp, string answer)
 {
     this.strExp = strExp;
     this.exp = exp;
     this.answer = answer;
 }
Пример #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnaryLogicExpression"/> class.
 /// </summary>
 /// <param name="argument">The expression.</param>
 protected UnaryLogicExpression(ILogicExpression argument)
 {
     this.argument = argument;
 }
Пример #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="And"/> class.
 /// </summary>
 /// <param name="firstMathExpression">The left operand.</param>
 /// <param name="secondMathExpression">The right operand.</param>
 /// <seealso cref="ILogicExpression"/>
 public And(ILogicExpression firstMathExpression, ILogicExpression secondMathExpression)
     : base(firstMathExpression, secondMathExpression)
 {
 }
 public ScenarioObservationRecord(ILogicExpression expr, int time)
     : base()
 {
     Expr = expr;
     Time = time;
 }