public InitialRecord(string expression) : base(WorldDescriptionRecordType.Initially) { this.PossibleFluents = new List<Fluent[]>(); this.logicExpression = ServiceLocator.Current.GetInstance<ILogicExpression>(); this.Expression = expression; }
public ImpossibleActionIfRecord(WorldAction worldAction, string ifExpression) : base(WorldDescriptionRecordType.ImpossibleActionIf) { this.logicExpression = ServiceLocator.Current.GetInstance <ILogicExpression>(); this.ifExpression = ifExpression; this.worldAction = worldAction; }
/// <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; }
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; }
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; }
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; }
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; }
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; }
/// <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(); } } }
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); }
public SimpleLogicExpressionTest() { _expression = new SimpleLogicExpression(); }
/// <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)); }
/// <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; }
/// <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); }
/// <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); }
/// <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); }
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); }
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; }
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; }
/// <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; }
/// <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; }
public IfElseExpression(ILogicExpression condition, IExpression branch1, IExpression branch2) { _condition = condition; _branch1 = branch1; _branch2 = branch2; }
/// <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); }
public NotExpression(ILogicExpression target) { _target = target; }
/// <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); }
public LogicWorkspaceItem(string strExp, ILogicExpression exp) : this(strExp, exp, null) { }
/// <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); }
/// <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 IfExpression(ILogicExpression condition, IExpression branch) { _condition = condition; _branch = branch; }
public WhileExpression(ILogicExpression condition, IExpression entry) { _condition = condition; _entry = entry; }
public ScenarioObservationRecord(ILogicExpression expr, int time) : base() { Expr = expr; Time = time; }
/// <summary> /// Initializes a new instance of the <see cref="Not"/> class. /// </summary> /// <param name="firstMathExpression">The expression.</param> public Not(ILogicExpression firstMathExpression) : base(firstMathExpression) { }
public LogicWorkspaceItem(string strExp, ILogicExpression exp, string answer) { this.strExp = strExp; this.exp = exp; this.answer = answer; }
/// <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; }
/// <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) { }