public EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core)
 {
     _nodeDescriptor = nodeDescriptor;
     _type           = type;
     _megaBytes      = megaBytes;
     _virtualCore    = core;
 }
 public Evaluator(Func<double> function, params Parameter[] parameters)
 {
     Dependencies.AddRange(parameters);
     this.function = function;
     this.constantVal = double.MinValue;
     this.type = EvaluatorType.function;
 }
 /// <summary>
 /// This is for resolving variables by setting the equation to zero.
 /// </summary>
 public Evaluator(SingleVariableEq function, params Parameter[] parameters)
 {
     Dependencies.AddRange(parameters);
     this.singleVarSetToZero = function;
     this.constantVal = double.MinValue;
     this.type = EvaluatorType.setToZero;
 }
 public EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core)
 {
     _nodeDescriptor = nodeDescriptor;
     _type = type;
     _megaBytes = megaBytes;
     _virtualCore = core;
 }
Example #5
0
 internal EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core,
     string rack = DefaultRackName)
 {
     _nodeDescriptor = nodeDescriptor;
     _evaluatorType = type;
     _megaBytes = megaBytes;
     _core = core;
     _rack = rack;
 }
Example #6
0
 // TODO[JIRA REEF-1054]: make runtimeName not optional
 internal EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core, string rack = DefaultRackName, string runtimeName = "")
 {
     _nodeDescriptor = nodeDescriptor;
     _evaluatorType  = type;
     _megaBytes      = megaBytes;
     _core           = core;
     _rack           = rack;
     _runtimeName    = runtimeName;
 }
Example #7
0
 /// <summary>
 /// 计算结果,如果表达式出错则抛出异常
 /// </summary>
 /// <param name="statement">表达式,如"1+2+3+4"</param>
 /// <returns>结果</returns>
 public static object Eval(string statement)
 {
     return(EvaluatorType.InvokeMember(
                "Eval",
                BindingFlags.InvokeMethod,
                null,
                Evaluator,
                new object[] { statement }
                ));
 }
Example #8
0
 internal EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core, string runtimeName, string rack = DefaultRackName)
 {
     _nodeDescriptor = nodeDescriptor;
     _evaluatorType = type;
     _megaBytes = megaBytes;
     _core = core;
     _rack = rack;
     if (!string.IsNullOrWhiteSpace(runtimeName) && !Enum.TryParse(runtimeName, true, out _runtimeName))
     {
         throw new ArgumentException("Unknown runtime name received " + runtimeName);
     }
 }
 internal EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core, string runtimeName, string rack = DefaultRackName)
 {
     _nodeDescriptor = nodeDescriptor;
     _evaluatorType  = type;
     _megaBytes      = megaBytes;
     _core           = core;
     _rack           = rack;
     if (!string.IsNullOrWhiteSpace(runtimeName) && !Enum.TryParse(runtimeName, true, out _runtimeName))
     {
         throw new ArgumentException("Unknown runtime name received " + runtimeName);
     }
 }
 public void SetType(EvaluatorType type)
 {
     lock (this)
     {
         if (_type != EvaluatorType.UNDECIDED)
         {
             var e = new InvalidOperationException("Cannot change a set evaluator type: " + _type);
             Exceptions.Throw(e, LOGGER);
         }
         _type = type;
     }
 }
Example #11
0
    protected override void Init()
    {
        base.Init();

        this.state       = EvaluatorType.None;
        sensoryComponent = new RavenSensoryComponent(this);

        //TODO 正确的传入参数
        weaponSystem = new WeaponSystem(this, 0, 0, 0);

        pathPlanner = new PathPlanner(this);

        targetSelectionSystem = new TargetSelectSystem(this);

        thinkComponent = new Goal_Think(this);

        thinkComponent.Activate();

        this.SteerComponent.SetAvoidWallParameter(3, 70, 0.15f);

        this.SteerComponent.WallAvoidanceOn();
    }
Example #12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ObstacleType != 0)
            {
                hash ^= ObstacleType.GetHashCode();
            }
            if (ObstacleStatus != 0)
            {
                hash ^= ObstacleStatus.GetHashCode();
            }
            if (EvaluatorType != 0)
            {
                hash ^= EvaluatorType.GetHashCode();
            }
            if (PredictorType != 0)
            {
                hash ^= PredictorType.GetHashCode();
            }
            return(hash);
        }
Example #13
0
    /// <summary>
    /// Configures the experiment from a text file.
    /// The method needs to be extended to extract data from the configuration file that is automatically loaded.
    /// </summary>
    public override void ConfigureExperiment()
    {
        string expCode = "";

        if (AvatarSystem.AvatarType == AvatarType.AbleBodied)
        {
            expCode = "_A";
        }
        else if (AvatarSystem.AvatarType == AvatarType.Transhumeral)
        {
            expCode = "_P";
        }

        if (debug)
        {
            configAsset = Resources.Load <TextAsset>("Experiments/" + this.gameObject.name + expCode);
        }
        else
        {
            configAsset = Resources.Load <TextAsset>("Experiments/" + ExperimentSystem.ActiveExperimentID + expCode);
        }



        // Convert configuration file to configuration class.

        configurator = JsonUtility.FromJson <GridReachingConfigurator>(configAsset.text);
        // Load data
        gridRows             = configurator.gridRows;
        gridColumns          = configurator.gridColumns;
        gridSpacing          = configurator.gridSpacing;
        gridHeightMultiplier = configurator.gridHeightMultiplier;
        gridReachMultiplier  = configurator.gridReachMultiplier;
        iterationsPerTarget  = configurator.iterationsPerTarget;
        evaluatorType        = configurator.evaluatorType;
        adaptiveSynergy      = configurator.adaptiveSynergy;
    }
Example #14
0
        /// <summary>
        /// Constructor only to be used by the bridge.
        /// </summary>
        /// <param name="str"></param>
        public EvaluatorDescriptorImpl(string str)
        {
            var settings = new Dictionary<string, string>();
            var components = str.Split(',');
            foreach (var component in components)
            {
                var pair = component.Trim().Split('=');
                if (pair == null || pair.Length != 2)
                {
                    var e = new ArgumentException("invalid component to be used as key-value pair:", component);
                    Exceptions.Throw(e, LOGGER);
                }
                settings.Add(pair[0], pair[1]);
            }
            string ipAddress;
            if (!settings.TryGetValue("IP", out ipAddress))
            {
                Exceptions.Throw(new ArgumentException("cannot find IP entry"), LOGGER);
            }
            ipAddress = ipAddress.Split('/').Last();
            string port;
            if (!settings.TryGetValue("Port", out port))
            {
                Exceptions.Throw(new ArgumentException("cannot find Port entry"), LOGGER);
            }
            var portNumber = 0;
            int.TryParse(port, out portNumber);
            string hostName;
            if (!settings.TryGetValue("HostName", out hostName))
            {
                Exceptions.Throw(new ArgumentException("cannot find HostName entry"), LOGGER);
            }
            string memory;
            if (!settings.TryGetValue("Memory", out memory))
            {
                Exceptions.Throw(new ArgumentException("cannot find Memory entry"), LOGGER);
            }
            var memoryInMegaBytes = 0;
            int.TryParse(memory, out memoryInMegaBytes);

            string core;
            if (!settings.TryGetValue("Core", out core))
            {
                Exceptions.Throw(new ArgumentException("cannot find Core entry"), LOGGER);
            }
            var vCore = 0;
            int.TryParse(core, out vCore);

            var ipEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), portNumber);

            _nodeDescriptor = new NodeDescriptorImpl { InetSocketAddress = ipEndPoint, HostName = hostName };
            _evaluatorType = EvaluatorType.CLR;
            _megaBytes = memoryInMegaBytes;
            _core = vCore;
        }
        public void FromString(string str)
        {
            Dictionary <string, string> settings = new Dictionary <string, string>();

            string[] components = str.Split(',');
            foreach (string component in components)
            {
                string[] pair = component.Trim().Split('=');
                if (pair == null || pair.Length != 2)
                {
                    var e = new ArgumentException("invalid component to be used as key-value pair:", component);
                    Exceptions.Throw(e, LOGGER);
                }
                settings.Add(pair[0], pair[1]);
            }
            string ipAddress;

            if (!settings.TryGetValue("IP", out ipAddress))
            {
                Exceptions.Throw(new ArgumentException("cannot find IP entry"), LOGGER);
            }
            ipAddress = ipAddress.Split('/').Last();
            string port;

            if (!settings.TryGetValue("Port", out port))
            {
                Exceptions.Throw(new ArgumentException("cannot find Port entry"), LOGGER);
            }
            int portNumber = 0;

            int.TryParse(port, out portNumber);
            string hostName;

            if (!settings.TryGetValue("HostName", out hostName))
            {
                Exceptions.Throw(new ArgumentException("cannot find HostName entry"), LOGGER);
            }
            string memory;

            if (!settings.TryGetValue("Memory", out memory))
            {
                Exceptions.Throw(new ArgumentException("cannot find Memory entry"), LOGGER);
            }
            int memoryInMegaBytes = 0;

            int.TryParse(memory, out memoryInMegaBytes);

            string core;

            if (!settings.TryGetValue("Core", out core))
            {
                Exceptions.Throw(new ArgumentException("cannot find Core entry"), LOGGER);
            }
            int vCore = 0;

            int.TryParse(core, out vCore);

            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), portNumber);

            _nodeDescriptor = new NodeDescriptorImpl();
            _nodeDescriptor.InetSocketAddress = ipEndPoint;
            _nodeDescriptor.HostName          = hostName;
            _type        = EvaluatorType.CLR;
            _megaBytes   = memoryInMegaBytes;
            _virtualCore = vCore;
        }
Example #16
0
 public Evaluator(double constantVal)
 {
     this.constantVal = constantVal;
     this.function = null;
     this.type = EvaluatorType.constant;
 }
 public void SetType(EvaluatorType type)
 {
     lock (this)
     {
         if (_type != EvaluatorType.UNDECIDED)
         {
             var e = new InvalidOperationException("Cannot change a set evaluator type: " + _type);
             Exceptions.Throw(e, LOGGER);
         }
         _type = type;
     }
 }
Example #18
0
        /// <summary>
        /// Constructor only to be used by the bridge.
        /// </summary>
        /// <param name="str"></param>
        public EvaluatorDescriptorImpl(string str)
        {
            var settings   = new Dictionary <string, string>();
            var components = str.Split(',');

            foreach (var component in components)
            {
                var pair = component.Trim().Split('=');
                if (pair == null || pair.Length != 2)
                {
                    var e = new ArgumentException("invalid component to be used as key-value pair:", component);
                    Exceptions.Throw(e, LOGGER);
                }
                settings.Add(pair[0], pair[1]);
            }

            // TODO[JIRA REEF-1054]: make runtimeName not optional
            string runtimeName;

            if (!settings.TryGetValue("RuntimeName", out runtimeName))
            {
                Exceptions.Throw(new ArgumentException("cannot find RuntimeName entry"), LOGGER);
            }
            string ipAddress;

            if (!settings.TryGetValue("IP", out ipAddress))
            {
                Exceptions.Throw(new ArgumentException("cannot find IP entry"), LOGGER);
            }
            ipAddress = ipAddress.Split('/').Last();
            string port;

            if (!settings.TryGetValue("Port", out port))
            {
                Exceptions.Throw(new ArgumentException("cannot find Port entry"), LOGGER);
            }
            var portNumber = 0;

            int.TryParse(port, out portNumber);
            string hostName;

            if (!settings.TryGetValue("HostName", out hostName))
            {
                Exceptions.Throw(new ArgumentException("cannot find HostName entry"), LOGGER);
            }
            string memory;

            if (!settings.TryGetValue("Memory", out memory))
            {
                Exceptions.Throw(new ArgumentException("cannot find Memory entry"), LOGGER);
            }
            var memoryInMegaBytes = 0;

            int.TryParse(memory, out memoryInMegaBytes);

            string core;

            if (!settings.TryGetValue("Core", out core))
            {
                Exceptions.Throw(new ArgumentException("cannot find Core entry"), LOGGER);
            }
            var vCore = 0;

            int.TryParse(core, out vCore);

            var ipEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), portNumber);

            _nodeDescriptor = new NodeDescriptorImpl {
                InetSocketAddress = ipEndPoint, HostName = hostName
            };
            _evaluatorType = EvaluatorType.CLR;
            _megaBytes     = memoryInMegaBytes;
            _core          = vCore;
            _runtimeName   = runtimeName;
        }