Пример #1
0
        // ReSharper restore InconsistentNaming

        protected SolverBase(ModelInfo modelInfo, float duration, int repeats, int samples, IModelBuilder modelBuilder = null)
        {
            if (modelBuilder == null)
            {
                modelBuilder = new ModelBuilder();
            }

            this.modelInfo = modelInfo;
            this.duration  = duration;
            SamplingParams = new SamplingParameters {
                RealizationCount = repeats, SampleCount = samples
            };

            rng = RNGFactory.GetRNG();

            _currentTime = 0.0f;

            model             = modelBuilder.BuildModel(modelInfo);
            _time             = model.Parameters.First(p => p.Name == "time");
            untriggeredEvents = null;
            triggeredEvents   = new Queue <TriggeredEvent>();
            scheduledEvents   = model.ScheduledEvents.Count > 0 ? new PriorityQueue <ScheduledEvent>(model.ScheduledEvents.Count) : null;
            trajectories      = AllocateRecordingArrays(model.Observables, SamplingParams);

            InitializePerformanceMeasurements();

            stopWatch = new Stopwatch();
        }
Пример #2
0
        public Vehicle()
        {
            this.trajectoryType = Trajectories.FOLLOWER;

            this.Id = 0;

            this.PositionX     = 1;
            this.PositionY     = 1;
            this.LastPositionX = 1;
            this.LastPositionY = 1;
            this.VelocityX     = 1;
            this.VelocityY     = 1;

            this.PendingPositionX = 1;
            this.PendingPositionY = 1;
            this.PendingVelocityX = 1;
            this.PendingVelocityY = 1;

            this.VehicleColor = Color.Blue;

            this.Type   = VehicleType.FOLLOWER;
            this.Access = -1;
            this.Course = RUMBO.ESTE;

            this.IsMovementPending = true;
            this.IsMacPending      = true;
            this.IsTxPending       = true;
            this.IsRxPending       = true;

            this.RegionsUsed = new List <AccessCoordinate>();

            this.Retransmissions = 0;
        }
Пример #3
0
    //new
    protected void Move()
    {
        if (m_direction.sqrMagnitude > m_stopDistance * m_stopDistance)
        {
            //Debug.Log("Move");
            if (HasWalAnim)
            {
                m_animationcomponent.IsWalking = true;
            }


            //Move
            float increment = Trajectories.UniformAccelerateMovement(m_groundSpeed, m_accel, Time.deltaTime);
            //m_direction.y = 0f;
            if (m_groundSpeed < m_MaxVelocity)
            {
                m_groundSpeed = Trajectories.UniformAccelerateVelocity(m_groundSpeed, m_accel, Time.deltaTime);
            }
            Vector3 fordward = transform.forward;
            fordward.y = 0f;
            this.GetComponent <Rigidbody>().MovePosition(GetComponent <Rigidbody>().position + fordward * increment);
            //transform.position = new Vector3(transform.position.x, YPlane, transform.position.z);
            //transform.position += transform.forward*increment;
            //m_state = TState.MOVE;
        }
    }
Пример #4
0
        public VehicleTdmaGt(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac,
                             Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions)
        {
            this.Id           = numId;
            this.VehicleColor = color;
            this.Type         = type;
            this.Mac          = mac;

            this.PositionX = initialPosition.X;
            this.PositionY = initialPosition.Y;

            this.TrajectoryType = tray;
            this.Limit          = limit;

            this.timeSegments      = timeDivisions;
            this.frequencySegments = frequencyDivisions;
            this.totalRegions      = this.timeSegments * this.frequencySegments;

            this.Alfa  = 0.4;
            this.Beta  = 0.3;
            this.Rho   = 1.4;
            this.Sigma = 1.3;

            this.MaximumValue = 10;
            this.MinimumValue = 0.2;
            this.Summatory    = this.MaximumValue + this.totalRegions * this.MinimumValue;
            this.NonZeroRatio = 0.5;

            this.lastAcess = -1;

            this.EstimationMatrix = new double[this.timeSegments, this.frequencySegments];

            this.initEstimationMatrix();
        }
Пример #5
0
        public Vehicle()
        {
            this.trajectoryType = Trajectories.FOLLOWER;

            this.Id = 0;

            this.PositionX = 1;
            this.PositionY = 1;
            this.LastPositionX = 1;
            this.LastPositionY = 1;
            this.VelocityX = 1;
            this.VelocityY = 1;

            this.PendingPositionX = 1;
            this.PendingPositionY = 1;
            this.PendingVelocityX = 1;
            this.PendingVelocityY = 1;

            this.VehicleColor = Color.Blue;

            this.Type = VehicleType.FOLLOWER;
            this.Access = -1;
            this.Course = RUMBO.ESTE;

            this.IsMovementPending = true;
            this.IsMacPending = true;
            this.IsTxPending = true;
            this.IsRxPending = true;

            this.RegionsUsed = new List<AccessCoordinate>();

            this.Retransmissions = 0;
            
        }
Пример #6
0
 public VehicleRrAloha(Coordinate initialPosition, int numId, Color color, VehicleType type,
                       MacTypes mac, Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions)
     : base(initialPosition, numId, color, type, mac, tray, limit)
 {
     this.timeSegments      = timeDivisions;
     this.frequencySegments = frequencyDivisions;
     this.FrameInformation  = new int[this.timeSegments, this.frequencySegments];
     this.AlreadyTx         = false;
 }
Пример #7
0
 public VehicleRrAloha(Coordinate initialPosition, int numId, Color color, VehicleType type,
     MacTypes mac, Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions)
     : base(initialPosition, numId, color, type, mac, tray, limit)
 {
     this.timeSegments = timeDivisions;
     this.frequencySegments = frequencyDivisions;
     this.FrameInformation = new int[this.timeSegments, this.frequencySegments];
     this.AlreadyTx = false;
 }
Пример #8
0
 public Vehicle(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac,
                Trajectories tray, Coordinate limit)
     : this(initialPosition.X, initialPosition.Y)
 {
     this.Id             = numId;
     this.VehicleColor   = color;
     this.Type           = type;
     this.Mac            = mac;
     this.TrajectoryType = tray;
     this.Limit          = limit;
 }
Пример #9
0
        /// <summary>
        /// Gets the best matching node for each instance in the dataset
        /// </summary>
        /// <returns>List of trajectories</returns>
        public List <Trajectory> GetTrajectories()
        {
            foreach (var instance in _dataset.Instances)
            {
                var node = _som.FindBestMatchingUnit(instance);

                Trajectories.Add(new Trajectory()
                {
                    Instance = instance,
                    Node     = node
                });
            }

            return(Trajectories);
        }
Пример #10
0
        public VehicleNccma(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac,
                            Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions) :
            base(initialPosition, numId, color, type, mac, tray, limit, timeDivisions, frequencyDivisions)
        {
            this.Cost = new double[this.totalRegions - 1]; //the auxiliary exploration is not performed on the transmission region
            this.ExplorationHistoryLength = 20;

            this.NonAccessMaximumValue = 4;

            this.Weight          = 0.7;
            this.ExplorationCost = 0.2;
            this.Slope           = 10.0;
            this.Attenuation     = 0.9;
            this.Displacement    = 10;

            this.NonZeroRatio = 1;
        }
Пример #11
0
        public VehicleNccma(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac,
            Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions) : 
            base(initialPosition, numId,color,type,mac,tray,limit,timeDivisions,frequencyDivisions)
        {
            this.Cost = new double[this.totalRegions-1]; //the auxiliary exploration is not performed on the transmission region
            this.ExplorationHistoryLength = 20;

            this.NonAccessMaximumValue = 4;

            this.Weight = 0.7;
            this.ExplorationCost = 0.2;
            this.Slope = 10.0;
            this.Attenuation = 0.9;
            this.Displacement = 10;

            this.NonZeroRatio = 1;
        }
Пример #12
0
        protected static Trajectories AllocateRecordingArrays(IEnumerable <Observable> observables, SamplingParameters samplingParams)
        {
            int numRealizations = samplingParams.RealizationCount;
            int numSamples      = samplingParams.SampleCount;

            var trajectories = new Trajectories(numSamples);

            foreach (Observable o in observables)
            {
                var runs = new float[numRealizations][];
                for (int i = 0; i < numRealizations; i++)
                {
                    runs[i] = new float[numSamples];
                }
                trajectories.Add(o, runs);
            }

            return(trajectories);
        }
Пример #13
0
        public VehicleTdmaGt(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac, 
            Trajectories tray, Coordinate limit, int timeDivisions, int frequencyDivisions)
        {

            this.Id = numId;
            this.VehicleColor = color;
            this.Type = type;
            this.Mac = mac;

            this.PositionX = initialPosition.X;
            this.PositionY = initialPosition.Y;

            this.TrajectoryType = tray;
            this.Limit = limit;

            this.timeSegments = timeDivisions;
            this.frequencySegments = frequencyDivisions;
            this.totalRegions = this.timeSegments * this.frequencySegments;

            this.Alfa = 0.4;
            this.Beta = 0.3;
            this.Rho = 1.4;
            this.Sigma = 1.3;

            this.MaximumValue = 10;
            this.MinimumValue = 0.2;
            this.Summatory = this.MaximumValue + this.totalRegions * this.MinimumValue;
            this.NonZeroRatio = 0.5;

            this.lastAcess = -1;

            this.EstimationMatrix = new double[this.timeSegments, this.frequencySegments];

            this.initEstimationMatrix();

        }
Пример #14
0
 public void AddTrajectory(Trajectory trajectory)
 {
     Trajectories.Add(trajectory);
     Sources.Add(trajectory.SourceFilePath);
 }
Пример #15
0
 void Ui_OnTrajectoryChange(int newTrajectory) => trajectory = (Trajectories)newTrajectory;
Пример #16
0
 public Vehicle(Coordinate initialPosition, int numId, Color color, VehicleType type, MacTypes mac, 
     Trajectories tray, Coordinate limit)
     : this(initialPosition.X, initialPosition.Y)
 {
     this.Id = numId;
     this.VehicleColor = color;
     this.Type = type;
     this.Mac = mac;
     this.TrajectoryType = tray;
     this.Limit = limit;
 }
Пример #17
0
    void FixedUpdate()
    {
        bool lightActive = GameMgr.GetInstance().GetStorageMgr().Get <bool>("settings", "light_active");

        m_lantern.gameObject.SetActive(lightActive);
        if (m_state != TState.ATTACK_BLOCK)
        {
            if (m_state == TState.MOVE)
            {
                m_attackComponent.ToAttack(false);
            }
            m_isGrouned     = IsGrounded();
            m_targetPoint.y = transform.position.y;
            Debug.DrawLine(transform.position, transform.position + transform.forward * 2f, Color.red);
            Vector3 direction   = m_targetPoint - transform.position;
            float   sqrDistance = direction.sqrMagnitude;
            Rotation(Time.fixedDeltaTime);
            m_move = Vector3.zero;
            if (sqrDistance > m_distanceToStop * m_distanceToStop)
            {
                direction = direction.normalized;
                float distanceInc = Trajectories.UniformAccelerateMovement(m_speed, m_accel, Time.fixedDeltaTime);
                if (m_speed < m_maxGroundSpeed)
                {
                    m_speed = Trajectories.UniformAccelerateVelocity(m_speed, m_accel, Time.fixedDeltaTime);
                }
                direction *= distanceInc;
                m_animationComponent.IsRunning = true;
                m_animationComponent.IsWalking = true;

                m_move.x = direction.x;
                m_move.z = direction.z;
                m_state  = m_state == TState.GO_TO_ATTACK ? m_state: TState.MOVE;
            }
            else
            {
                if (m_state != TState.ATTACK_NO_BLOCK)
                {
                    m_animationComponent.IsRunning = false;
                    m_animationComponent.IsWalking = false;
                    m_speed = m_initialSpeed;
                }
            }

            if (!m_isGrouned)
            {
                float distanceGravityInc = Trajectories.UniformAccelerateMovement(m_gravityVelocity, m_gravity, Time.fixedDeltaTime);
                if (m_gravityVelocity < m_maxAirSpeed)
                {
                    m_gravityVelocity = Trajectories.UniformAccelerateVelocity(m_gravityVelocity, m_gravity, Time.fixedDeltaTime);
                }
                m_move.y = -distanceGravityInc;
                m_state  = TState.MOVE;
            }
            else
            {
                m_gravityVelocity = 0f;
            }

            if (m_state == TState.MOVE || m_state == TState.GO_TO_ATTACK)
            {
                m_characterController.Move(m_move);
            }

            if (m_state == TState.GO_TO_ATTACK)
            {
                if (m_attackComponent.CheckCanAttack())
                {
                    m_state             = TState.ATTACK_BLOCK;
                    m_preparingToAttack = true;
                    ThrowAttack();
                }
                else
                {
                    m_attackComponent.ToAttack(false);
                }
            }
        }
        else
        {
            if (m_preparingToAttack)
            {
                //orientamos el personaje para atacar...
                if (Rotation(Time.fixedDeltaTime))
                {
                    ThrowAttack();
                }
            }
        }
    }
 private void SetTrajectories(Trajectories msg)
 {
     StartCoroutine(arm.ExecuteTrajectories(msg.trajectories));
 }