public AutoSimplifyTransformation(MathIdentifier id, CreatePattern pattern, EstimatePlan plan, ManipulatePort simplify)
 {
     _id = id;
     _pattern = pattern;
     _simplify = simplify;
     _plan = plan;
 }
 public AutoSimplifyTransformation(MathIdentifier id, Predicate<Port> supportsPort, EstimatePlan plan, ManipulatePort simplify)
 {
     _id = id;
     _supportsPort = supportsPort;
     _simplify = simplify;
     _plan = plan;
 }
예제 #3
0
 public virtual void MergeToCoalescedTree(MathIdentifier patternId, List<CoalescedTreeNode> parents)
 {
     List<CoalescedTreeNode> nodes = _condition.MergeToCoalescedTree(parents);
     MergeGroupToCoalescedTree(patternId, nodes);
     foreach(CoalescedTreeNode node in nodes)
         node.Subscribe(patternId);
 }
 public GenericPropagationTheorem(MathIdentifier id, MathIdentifier providedPropertyId, ImpliesProperty impliesProperty, BuildProperty buildProperty)
 {
     this.id = id;
     this.providedPropertyId = providedPropertyId;
     this.impliesProperty = impliesProperty;
     this.buildProperty = buildProperty;
 }
예제 #5
0
 public CustomDataRef(Type instanceType, IConversionRouter router, ICustomData instance)
 {
     _instanceType = instanceType;
     _router = router;
     _typeId = router.TypeIdentifier;
     _instance = instance;
 }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    ReadOnlySignalSet squares = StdBuilder.Square(port.OutputSignals);
                    Signal one = IntegerValue.ConstantOne;
                    SignalSet outputs = new SignalSet();
                    for(int i = 0; i < manipulatedInputs.Count; i++)
                        outputs.Add((one + squares[i]) * manipulatedInputs[i]);
                    return outputs;
                }));

            MathIdentifier typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
            ITheoremProvider basicProvider;
            if(!library.TryLookupTheoremType(typeId, out basicProvider))
            {
                basicProvider = Binder.GetInstance<ITransformationTheoremProvider, MathIdentifier>(typeId);
                library.AddTheoremType(basicProvider);
            }
            ((ITransformationTheoremProvider)basicProvider).Add(
                new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    Signal[] ret = new Signal[transformedInputs.Count];
                    for(int i = 0; i < ret.Length; i++)
                        ret[i] = StdBuilder.Sine(transformedInputs[i]) / StdBuilder.Cosine(transformedInputs[i]);
                    return ret;
                }));
        }
 public DerivativeTransformation(MathIdentifier id, MathIdentifier supportedEntityId, EstimateDerivePlan plan, Derive derive)
 {
     _id = id;
     _supportedEntityId = supportedEntityId;
     _derive = derive;
     _plan = plan;
 }
        public static void RegisterTheorems(ILibrary library)
        {
            Analysis.DerivativeTransformation.Provider.Add(
                new Analysis.DerivativeTransformation(_entityId,
                delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
                {
                    Signal[] outputs = new Signal[manipulatedInputs.Count];
                    ReadOnlySignalSet cotangents = StdBuilder.Cotangent(port.InputSignals);
                    for(int i = 0; i < outputs.Length; i++)
                        outputs[i] = Std.Multiply(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
                    return StdBuilder.Negate(outputs);
                }));

            MathIdentifier typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
            ITheoremProvider basicProvider;
            if(!library.TryLookupTheoremType(typeId, out basicProvider))
            {
                basicProvider = Binder.GetInstance<ITransformationTheoremProvider, MathIdentifier>(typeId);
                library.AddTheoremType(basicProvider);
            }
            ((ITransformationTheoremProvider)basicProvider).Add(
                new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
                delegate() { return new Pattern(new EntityCondition(_entityId)); },
                delegate(Port port) { return ManipulationPlan.DoAlter; },
                delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
                {
                    return StdBuilder.Invert(StdBuilder.Sine(transformedInputs));
                    //Signal[] ret = new Signal[transformedInputs.Count];
                    //for(int i = 0; i < ret.Length; i++)
                    //    ret[i] = Std.Invert(Std.Sine(transformedInputs[i]));
                    //return ret;
                }));
        }
예제 #9
0
 protected NewPortCommand(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _entityId = MathIdentifier.Parse(info.GetString("entityId"));
     _inputCnt = info.GetInt32("inputCount");
     _busCnt = info.GetInt32("busCount");
 }
 /// <param name="sticky">If true the property will stay attached (but updated) when the membership changes. If false the property will be removed. If the new state is unknown, the property is removed in both cases.</param>
 public CategoryMembershipProperty(Category category, ECategoryMembership categoryMembership, bool sticky)
 {
     _category = category;
     _categoryMembership = categoryMembership;
     _isSticky = sticky;
     _propertyId = category.AssociatedPropertyIdentifier;
 }
예제 #11
0
 public ConversionDistance(MathIdentifier canConvertFrom, int cost, bool lossless, ConversionRouter nextHop, Converter<ValueStructure, ValueStructure> convert)
 {
     this.CanConvertFrom = canConvertFrom;
     this.Cost = cost;
     this.Lossless = lossless;
     this.NextHop = nextHop;
     this.Convert = convert;
 }
예제 #12
0
 public ConversionRouter(MathIdentifier structureId)
 {
     this.structureId = structureId;
     this.losslessNeighbors = new Dictionary<MathIdentifier, ConversionRoute>();
     this.lossyNeighbors = new Dictionary<MathIdentifier, ConversionRoute>();
     this.targetNeighbors = new Dictionary<MathIdentifier, ConversionRouter>();
     this.vector = new Dictionary<MathIdentifier, ConversionDistance>();
 }
예제 #13
0
 public BasicTransformation(MathIdentifier id, MathIdentifier transformationTypeId, Predicate<Port> supportsPort, EstimatePlan plan, ManipulatePort transform)
 {
     _id = id;
     _transformationTypeId = transformationTypeId;
     _supportsPort = supportsPort;
     _transform = transform;
     _plan = plan;
 }
        /// <summary>Port Instance Constructor</summary>
        protected GenericMathOpArchitecture(MathIdentifier id, MathIdentifier entityId, Port port)
            : base(id, entityId, true)
        {
            if(port == null) throw new ArgumentNullException("port");
            //System.Diagnostics.Debug.Assert(SupportsPort(port));
            SetPort(port);

            for(int i = 0; i < port.OutputSignalCount; i++)
                port.OutputSignals[i].PostNewValue(UndefinedSymbol.Instance);
        }
예제 #15
0
 private List<IArchitectureFactory> AddEntity(MathIdentifier entityId)
 {
     List<IArchitectureFactory> value;
     if(!_table.TryGetValue(entityId, out value))
     {
         value = new List<IArchitectureFactory>();
         _table.Add(entityId, value);
     }
     return value;
 }
        /// <summary>Port Instance Constructor</summary>
        protected GenericSimpleArchitecture(MathIdentifier entityId, bool isMathematicalOperator, Port port, int internalSignalCount)
            : base(entityId, entityId, isMathematicalOperator)
        {
            _internalSignals = new Signal[internalSignalCount];
            for(int i = 0; i < _internalSignals.Length; i++)
                _internalSignals[i] = Binder.CreateSignal();

            //System.Diagnostics.Debug.Assert(SupportsPort(port));
            SetPort(port);
            _sensedSignals = new SignalSet();
            SenseSignals(port.InputSignals, _internalSignals, port.Buses, port.OutputSignals);
            Action(port.InputSignals, port.OutputSignals, _internalSignals, port.Buses);
        }
        public CompoundArchitecture(MathIdentifier id, MathIdentifier entityId, Port port, IMathSystem system)
            : base(id, entityId, false)
        {
            this.inputSignals = port.InputSignals;
            this.outputSignals = port.OutputSignals;
            this.system = system;
            this.system.OutputValueChanged += system_OutputValueChanged;

            SetPort(port);

            for(int i = 0; i < inputSignals.Count; i++)
                inputSignals[i].ValueChanged += CompoundArchitecture_SignalValueChanged;
            system.PushInputValueRange(inputSignals);
        }
        public GenericArchitecture(MathIdentifier id, MathIdentifier entityId, bool isMathematicalOperator, Port port, Predicate<Port> portSupport, int internalSignalCount, params ProcessBase[] processes)
            : base(id, entityId, isMathematicalOperator)
        {
            _processes = processes;
            _portSupport = portSupport;
            _internalSignals = new Signal[internalSignalCount];
            for(int i = 0; i < _internalSignals.Length; i++)
                _internalSignals[i] = Binder.CreateSignal();

            //System.Diagnostics.Debug.Assert(SupportsPort(port));
            SetPort(port);

            for(int i = 0; i < processes.Length; i++)
                processes[i].Register(port.InputSignals, port.OutputSignals, _internalSignals, port.Buses);
        }
예제 #19
0
 public SignalSet Transform(IEnumerable<Signal> signals, MathIdentifier transformationTypeId, ConfigureTransformation configure, bool ignoreHold)
 {
     ITransformationTheoremProvider provider = (ITransformationTheoremProvider)_library.LookupTheoremType(transformationTypeId);
     TransformationManipulationVisitor visitor = new TransformationManipulationVisitor(provider, configure);
     return _manipulator.Manipulate(signals, visitor, ignoreHold);
 }
예제 #20
0
 public IEntity LookupEntity(MathIdentifier entityId)
 {
     return(_entities[entityId]);
 }
예제 #21
0
 public bool ContainsEntity(MathIdentifier entityId)
 {
     return(_entities.Contains(entityId));
 }
예제 #22
0
 public bool TryLookupTheoremType(MathIdentifier theoremTypeId, out ITheoremProvider provider)
 {
     return(_theorems.TryGetValue(theoremTypeId, out provider));
 }
예제 #23
0
 public bool ContainsTheoremType(MathIdentifier theoremTypeId)
 {
     return(_theorems.Contains(theoremTypeId));
 }
 public void RemoveGroup(MathIdentifier patternId)
 {
     _groupAxis.Remove(patternId);
 }
예제 #25
0
        public void ReadSystems(XmlReader reader, bool multiple)
        {
            _reader     = reader;
            _fsm.Reader = reader;
            _fsm.Reset();

            Dictionary <Guid, Guid> signalMappings = new Dictionary <Guid, Guid>();
            Dictionary <Guid, Guid> busMappings    = new Dictionary <Guid, Guid>();

            bool active = false;

            BuilderState state;

            while (BuilderState.Idle != (state = _fsm.ReadNextState()) || active)
            {
                switch (state)
                {
                case BuilderState.System:
                    int inputCnt  = int.Parse(_reader.GetAttribute("inputCount"), Config.InternalNumberFormat);
                    int outputCnt = int.Parse(_reader.GetAttribute("outputCount"), Config.InternalNumberFormat);
                    int busCnt    = int.Parse(_reader.GetAttribute("busCount"), Config.InternalNumberFormat);
                    _reader.Read();
                    _builder.BeginBuildSystem(inputCnt, outputCnt, busCnt);
                    active = true;
                    break;

                case BuilderState.Signals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Signal")
                    {
                        Guid   myGuid   = new Guid(_reader.GetAttribute("iid"));
                        string label    = _reader.GetAttribute("label");
                        bool   hold     = bool.Parse(_reader.GetAttribute("hold"));
                        bool   isSource = bool.Parse(_reader.GetAttribute("isSource"));
                        _reader.Read();
                        Guid tGuid = _builder.BuildSignal(label, hold, isSource);
                        signalMappings.Add(myGuid, tGuid);
                    }
                    break;

                case BuilderState.Buses:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Bus")
                    {
                        Guid   myGuid = new Guid(_reader.GetAttribute("iid"));
                        string label  = _reader.GetAttribute("label");
                        _reader.Read();
                        Guid tGuid = _builder.BuildBus(label);
                        busMappings.Add(myGuid, tGuid);
                    }
                    break;

                case BuilderState.Ports:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Port")
                    {
                        InstanceIdSet inputSignals  = new InstanceIdSet();
                        InstanceIdSet outputSignals = new InstanceIdSet();
                        InstanceIdSet buses         = new InstanceIdSet();
                        //Guid myGuid = new Guid(_reader.GetAttribute("iid"));
                        MathIdentifier entityId = MathIdentifier.Parse(_reader.GetAttribute("entityId"));
                        _reader.ReadToDescendant("InputSignals");
                        _reader.Read();
                        while (_reader.IsStartElement("SignalRef"))
                        {
                            inputSignals.Add(signalMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _reader.ReadToFollowing("OutputSignals");
                        _reader.Read();
                        while (_reader.IsStartElement("SignalRef"))
                        {
                            outputSignals.Add(signalMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _reader.ReadToFollowing("Buses");
                        _reader.Read();
                        while (_reader.IsStartElement("BusRef"))
                        {
                            buses.Add(busMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _builder.BuildPort(entityId, inputSignals, outputSignals, buses);
                    }
                    break;

                case BuilderState.SignalDetails:
                    _reader.Read();
                    while (ReadToElement())
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.GetAttribute("iid"))];
                        switch (_reader.LocalName)
                        {
                        case "SignalValue":
                        {
                            CustomDataPack <IValueStructure> pack = CustomDataPack <IValueStructure> .Repack(_reader.ReadInnerXml(), signalMappings, busMappings);

                            _builder.AppendSignalValue(tGuid, pack);
                        }
                        break;

                        case "SignalProperty":
                        {
                            CustomDataPack <IProperty> pack = CustomDataPack <IProperty> .Repack(_reader.ReadInnerXml(), signalMappings, busMappings);

                            _builder.AppendSignalProperty(tGuid, pack);
                        }
                        break;

                        case "SignalConstraint":
                        {
                            CustomDataPack <IProperty> pack = CustomDataPack <IProperty> .Repack(_reader.ReadInnerXml(), signalMappings, busMappings);

                            _builder.AppendSignalConstraint(tGuid, pack);
                        }
                        break;
                        }
                    }
                    break;

                case BuilderState.InputSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemInputSignal(tGuid);
                    }
                    break;

                case BuilderState.OutputSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemOutputSignal(tGuid);
                    }
                    break;

                case BuilderState.NamedSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        string name  = _reader.GetAttribute("name");
                        Guid   tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemNamedSignal(tGuid, name);
                    }
                    break;

                case BuilderState.NamedBuses:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "BusRef")
                    {
                        string name  = _reader.GetAttribute("name");
                        Guid   tGuid = busMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemNamedBus(tGuid, name);
                    }
                    break;

                case BuilderState.Idle:
                    _builder.EndBuildSystem();
                    active = false;
                    if (!multiple)
                    {
                        return;
                    }
                    break;
                }
            }
        }
예제 #26
0
 public InputSignalsPropertyCondition(MathIdentifier propertyType, CombinationMode mode)
 {
     _propertyType = propertyType;
     _mode         = mode;
 }
예제 #27
0
 public bool EqualsById(MathIdentifier otherCategoryId)
 {
     return(_id.Equals(otherCategoryId));
 }
예제 #28
0
 public bool EqualsById(MathIdentifier otherStructureId)
 {
     return(TypeId.Equals(otherStructureId));
 }
예제 #29
0
 public ICustomDataRef LookupCustomDataType(MathIdentifier typeId)
 {
     return(_customData[typeId]);
 }
예제 #30
0
        private Port _port; // = null;

        protected ArchitectureBase(MathIdentifier id, MathIdentifier entityId, bool isMathematicalOperator)
        {
            _id       = id;
            _entityId = entityId;
            _isMathematicalOperator = isMathematicalOperator;
        }
예제 #31
0
 public bool TryLookupArbitraryType(MathIdentifier id, out Type type)
 {
     return(_arbitraryType.TryGetValue(id, out type));
 }
예제 #32
0
 public Type LookupArbitraryType(MathIdentifier id)
 {
     return(_arbitraryType[id]);
 }
 public CompoundArchitectureFactory(MathIdentifier architectureId, MathIdentifier entityId, string xml)
 {
     _architectureId = architectureId;
     _entityId = entityId;
     _xml = xml;
     IEntity dummy = MathSystem.ReadXmlEntity(xml, new MathIdentifier("Dummy", "Temp"), string.Empty);
     _inputCnt = dummy.InputSignals.Length;
     _outputCnt = dummy.OutputSignals.Length;
     _busCnt = dummy.Buses.Length;
 }
예제 #34
0
 protected CategoryBase(MathIdentifier id)
 {
     _id = id;
 }
예제 #35
0
 public bool TryLookupProperty <T>(MathIdentifier propertyId, out T value) where T : Property
 {
     return(_properties.TryGetValue <T>(propertyId, out value));
 }
 public void Unsubscribe(MathIdentifier patternId)
 {
     _subscriptionAxis.Remove(patternId);
 }
예제 #37
0
 public bool ContainsArbitraryType(MathIdentifier id)
 {
     return(_arbitraryType.ContainsKey(id));
 }
 public EntityImplementationAttribute(MathIdentifier entityId)
 {
     _entityId = entityId;
 }
예제 #39
0
 /// <summary>Architecture Builder Constructor</summary>
 protected GenericMathOpArchitecture(MathIdentifier entityId) : base(entityId, entityId, true)
 {
 }
예제 #40
0
 public bool ContainsCustomDataType(MathIdentifier typeId)
 {
     return(_customData.Contains(typeId));
 }
예제 #41
0
 public ITheoremProvider LookupTheoremType(MathIdentifier theoremTypeId)
 {
     return(_theorems[theoremTypeId]);
 }
 public AutoSimplifyTransformation(MathIdentifier supportedEntityId, EstimatePlan plan, ManipulatePort simplify)
     : this(supportedEntityId.DerivePostfix("AutoSimplify"), delegate() { return new Pattern(new EntityCondition(supportedEntityId)); }, plan, simplify) { }
예제 #43
0
 public bool TryFindEntityByLabel(string label, out MathIdentifier id)
 {
     return(_entities.TryFindDomainOfLabel(label, out id));
 }
예제 #44
0
 public Signal Function(MathIdentifier entityId, Signal argument1, Signal argument2)
 {
     return(Function(context.Library.LookupEntity(entityId), argument1, argument2));
 }
예제 #45
0
 public bool TryLookupEntity(MathIdentifier entityId, out IEntity value)
 {
     return(_entities.TryGetValue(entityId, out value));
 }
예제 #46
0
 public Signal Function(MathIdentifier entityId, IList <Signal> arguments)
 {
     return(Function(context.Library.LookupEntity(entityId), arguments));
 }
예제 #47
0
 public Signal Transform(Signal signal, MathIdentifier transformationTypeId, bool ignoreHold)
 {
     ITransformationTheoremProvider provider = (ITransformationTheoremProvider)_library.LookupTheoremType(transformationTypeId);
     TransformationManipulationVisitor visitor = new TransformationManipulationVisitor(provider);
     return _manipulator.Manipulate(signal, visitor, ignoreHold);
 }
예제 #48
0
 public ReadOnlySignalSet Functions(MathIdentifier entityId, Signal argument1, Signal argument2)
 {
     return(Functions(context.Library.LookupEntity(entityId), argument1, argument2));
 }
 public CompoundArchitectureFactory(MathIdentifier architectureId, MathIdentifier entityId, string xml, int inputCount, int outputCount, int busCount)
 {
     _architectureId = architectureId;
     _entityId = entityId;
     _inputCnt = inputCount;
     _outputCnt = outputCount;
     _busCnt = busCount;
     _xml = xml;
 }
예제 #50
0
 public ReadOnlySignalSet Functions(MathIdentifier entityId, IList <Signal> arguments)
 {
     return(Functions(context.Library.LookupEntity(entityId), arguments));
 }
        public CompoundArchitectureFactory(MathIdentifier architectureId, MathIdentifier entityId, MathSystem system)
        {
            if(system == null)
                throw new ArgumentNullException("system");

            _architectureId = architectureId;
            _entityId = entityId;
            _inputCnt = system.InputCount;
            _outputCnt = system.OutputCount;
            _busCnt = system.BusCount;
            _xml = system.WriteXml(false);
        }
 public EntityImplementationAttribute(MathIdentifier entityId)
 {
     _entityId = entityId;
 }
 public OutputSignalsPropertyCondition(MathIdentifier propertyType, CombinationMode mode)
 {
     _propertyType = propertyType;
     _mode = mode;
 }
예제 #54
0
 public bool EqualsById(MathIdentifier otherPropertyId)
 {
     return(TypeId.Equals(otherPropertyId));
 }
 public void Subscribe(MathIdentifier patternId)
 {
     _subscriptionAxis.Add(patternId);
 }
예제 #56
0
 public bool TryLookupCustomDataType(MathIdentifier typeId, out ICustomDataRef data)
 {
     return(_customData.TryGetValue(typeId, out data));
 }
 public void AddGroup(MathIdentifier patternId, string label)
 {
     _groupAxis.Add(patternId, label);
 }
예제 #58
0
 /// <summary>Architecture Builder Constructor</summary>
 protected GenericSimpleArchitecture(MathIdentifier entityId, bool isMathematicalOperator) : base(entityId, entityId, isMathematicalOperator)
 {
 }
 public bool EqualsById(MathIdentifier otherStructureId)
 {
     return TypeId.Equals(otherStructureId);
 }
예제 #60
0
 public override void Add(MathIdentifier id, Entity value)
 {
     base.Add(id, value);
     AddSymbol(value.Symbol).Add(value);
 }