コード例 #1
0
 public AutoSimplifyTransformation(MathIdentifier id, CreatePattern pattern, EstimatePlan plan, ManipulatePort simplify)
 {
     _id = id;
     _pattern = pattern;
     _simplify = simplify;
     _plan = plan;
 }
コード例 #2
0
 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);
 }
コード例 #4
0
 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;
 }
コード例 #6
0
        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;
                }));
        }
コード例 #7
0
 public DerivativeTransformation(MathIdentifier id, MathIdentifier supportedEntityId, EstimateDerivePlan plan, Derive derive)
 {
     _id = id;
     _supportedEntityId = supportedEntityId;
     _derive = derive;
     _plan = plan;
 }
コード例 #8
0
        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");
 }
コード例 #10
0
 /// <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;
 }
コード例 #14
0
        /// <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;
 }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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));
 }
コード例 #24
0
 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]);
 }
コード例 #33
0
 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));
 }
コード例 #36
0
 public void Unsubscribe(MathIdentifier patternId)
 {
     _subscriptionAxis.Remove(patternId);
 }
コード例 #37
0
 public bool ContainsArbitraryType(MathIdentifier id)
 {
     return(_arbitraryType.ContainsKey(id));
 }
コード例 #38
0
 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]);
 }
コード例 #42
0
 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));
 }
コード例 #49
0
 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));
 }
コード例 #51
0
        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);
        }
コード例 #52
0
 public EntityImplementationAttribute(MathIdentifier entityId)
 {
     _entityId = entityId;
 }
コード例 #53
0
 public OutputSignalsPropertyCondition(MathIdentifier propertyType, CombinationMode mode)
 {
     _propertyType = propertyType;
     _mode = mode;
 }
コード例 #54
0
 public bool EqualsById(MathIdentifier otherPropertyId)
 {
     return(TypeId.Equals(otherPropertyId));
 }
コード例 #55
0
 public void Subscribe(MathIdentifier patternId)
 {
     _subscriptionAxis.Add(patternId);
 }
コード例 #56
0
 public bool TryLookupCustomDataType(MathIdentifier typeId, out ICustomDataRef data)
 {
     return(_customData.TryGetValue(typeId, out data));
 }
コード例 #57
0
 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)
 {
 }
コード例 #59
0
 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);
 }