Exemplo n.º 1
0
 public VisualizerUpdateContext(SolutionSnapshot theSnapshot, DisplayModel theDisplay, VisualizerBindingExpressionModel theBinding, ModelModel theModel)
 {
     Snapshot = theSnapshot;
     Display  = theDisplay;
     Binding  = theBinding;
     Model    = theModel;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize the solution with the model and snapshot.
 /// </summary>
 /// <param name="theModel">Model that the solution is supposed to solve.</param>
 /// <param name="theSnapshot">Solution snapshot.</param>
 /// <param name="duration">Time taken to find the solution.</param>
 public SolutionModel(ModelModel theModel, SolutionSnapshot theSnapshot, TimeSpan duration)
 {
     Model    = theModel;
     Snapshot = theSnapshot;
     Snapshot = new SolutionSnapshot();
     Duration = duration;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initialize a workspace with a model.
 /// </summary>
 public WorkspaceModel(ModelModel theModel)
 {
     Model           = theModel;
     Model.Workspace = this;
     Solution        = new SolutionModel(Model);
     Display         = new DisplayModel(Model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Validate the constraint expression.
        /// </summary>
        /// <param name="theModel">Model to validate.</param>
        /// <param name="theContext">Validation context to capture the errors.</param>
        /// <returns>
        /// Return true if the constraint is valid, return false if
        /// the constraint is not valid.
        /// </returns>
        public override bool Validate(ModelModel theModel, ModelValidationContext theContext)
        {
            if (Expression.Node == null)
            {
                return(false);
            }

            var variableCaptureVisitor = new ConstraintVariableReferenceCaptureVisitor();

            Expression.Node.AcceptVisitor(variableCaptureVisitor);
            var variableReferences = variableCaptureVisitor.GetReferences();

            foreach (var singletonVariableReference in variableReferences.SingletonVariableReferences)
            {
                if (theModel.Variables.FirstOrDefault(_ => _.Name.IsEqualTo(singletonVariableReference.VariableName)) == null)
                {
                    theContext.AddError($"Missing singleton variable {singletonVariableReference.VariableName}");
                    return(false);
                }
            }

            foreach (var aggregateVariableReference in variableReferences.AggregateVariableReferences)
            {
                if (theModel.Aggregates.FirstOrDefault(_ => _.Name.IsEqualTo(aggregateVariableReference.VariableName)) == null)
                {
                    theContext.AddError($"Missing aggregate variable {aggregateVariableReference.VariableName}");
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initialize a workspace with default values.
 /// </summary>
 public WorkspaceModel()
 {
     Model           = new ModelModel(this);
     Model.Workspace = this;
     Solution        = new SolutionModel(Model);
     Display         = new DisplayModel(Model);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initialize a variable with a variable name.
 /// </summary>
 public SingletonVariableModel(ModelModel theModel, ModelName variableName)
     : base(theModel.Workspace, variableName, new InlineDomainModel())
 {
 }
 public AllDifferentConstraintModel(ModelModel theModel)
 {
     Parent     = theModel;
     Expression = new AllDifferentConstraintExpressionModel();
 }
 public AllDifferentConstraintModel(ModelModel theModel, ModelName theName, AllDifferentConstraintExpressionModel theExpressionModel)
     : base(theName)
 {
     Parent     = theModel;
     Expression = theExpressionModel;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a variable with a variable name.
 /// </summary>
 protected VariableModel(ModelModel theModel, ModelName variableName)
     : base(variableName)
 {
     Parent           = theModel;
     DomainExpression = new VariableDomainExpressionModel();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initialize a display model with default values.
 /// </summary>
 /// <param name="theModel"></param>
 public DisplayModel(ModelModel theModel)
 {
     Visualizers   = new List <VisualizerModel>();
     this.bindings = new List <VisualizerBindingExpressionModel>();
     this.model    = theModel;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Validate the constraint.
 /// </summary>
 /// <returns>
 /// Return true if the constraint is valid, return false if
 /// the constraint is not valid.
 /// </returns>
 public virtual bool Validate(ModelModel theModel)
 {
     return(Validate(theModel, new ModelValidationContext()));
 }
Exemplo n.º 12
0
 public ExpressionConstraintModel(ModelModel theModel, ConstraintExpressionModel theExpression)
     : base(new ModelName())
 {
     Parent          = theModel;
     this.expression = theExpression;
 }
Exemplo n.º 13
0
 public ExpressionConstraintModel(ModelModel theModel, ModelName theName)
     : base(theName)
 {
     Parent          = theModel;
     this.expression = new ConstraintExpressionModel();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initialize a shared domain with a name and domain expression.
 /// </summary>
 public SharedDomainModel(ModelModel theModel, ModelName theName, SharedDomainExpressionModel theExpression)
     : base(theName)
 {
     Parent      = theModel;
     _expression = theExpression;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Validate the constraint placing errors into the validation context.
 /// </summary>
 /// <returns>
 /// Return true if the constraint is valid, return false if
 /// the constraint is not valid.
 /// </returns>
 public abstract bool Validate(ModelModel theModel, ModelValidationContext theContext);
Exemplo n.º 16
0
 /// <summary>
 /// Initialize the solution with the model.
 /// </summary>
 /// <param name="theModel">Model that the solution is supposed to solve.</param>
 public SolutionModel(ModelModel theModel)
 {
     Model    = theModel;
     Snapshot = new SolutionSnapshot();
     Snapshot = new SolutionSnapshot();
 }
Exemplo n.º 17
0
 public PropertyUpdateContext(SolutionSnapshot theSnapshot, DisplayModel theDisplay, ModelModel theModel)
 {
     Snapshot = theSnapshot;
     Display  = theDisplay;
     Model    = theModel;
 }