public void SetParams(int index, int countRate, int mass, int maxMass, int massDelta,
                              int massDeltaPlus, int massToDevide, bool allowMove, decimal feedRate,
                              int poison, int poisonDelta, int poisonResitrance, int sleep,
                              int consumentOrder, Point position, ICore core, IEnv enviroment)
        {
            OrganismIndex = index;

            CountRate = countRate;

            Mass          = mass;
            MaxMass       = maxMass;
            MassDelta     = massDelta;
            MassDeltaPlus = massDeltaPlus;
            MassToDevide  = massToDevide;

            AllowMove = allowMove;

            FeedRate = feedRate;

            PoisonLevel      = poison;
            PoisonDelta      = poisonDelta;
            PoisonResistence = poisonResitrance;

            SleepCicles = sleep;

            ConsumentOrder = consumentOrder;

            Position = position;

            Enviroment = enviroment;
            Core       = core.Create();
        }
Exemple #2
0
 public NodeContext(ExprNode parent, IEnv env, int line, int column)
 {
     Parent = parent;
     Env    = env ?? throw new ArgumentNullException("env");
     Line   = line;
     Column = column;
 }
        public virtual IOrganism Create(IEnv enviroment, ICore core, Point position, int index)
        {
            IOrganism org = new Organism();

            org.Init(enviroment, core, position, index);
            return(org);
        }
        async Task Run(IEnv env)
        {
            _expectedCount = 0M;
            var endpoints = Servers.Select(m => new SimEndpoint(m, Port)).ToArray();

            var lib = new BackendClient(env, endpoints);

            await lib.AddItem(0, 1);

            _expectedCount = 1M;

            for (int i = 0; i < Iterations; i++)
            {
                try {
                    var curr = i % RingSize;
                    var next = (i + 1) % RingSize;
                    await lib.MoveItem(curr, next, 1);

                    await env.Delay(Delay);
                } catch (ArgumentException ex) {
                    env.Error("Unexpected error", ex);
                }
            }

            _actualCount = await lib.Count();

            if (HaltOnCompletion)
            {
                env.Halt("DONE");
            }
        }
Exemple #5
0
        public static async Task SendWithBackOff(IEnv env, int recipient, object msg)
        {
            var counter = 0;

            while (true)
            {
                try {
                    await env.Send(recipient, msg);

                    return;
                } catch (Exception ex) {
                    if (counter < 10)
                    {
                        counter++;
                        var sleep = TimeSpan.FromSeconds(Math.Pow(2, counter));
                        env.Debug($"Retrying send on {ex.Message} #{counter} after {sleep.TotalSeconds} seconds");
                        await env.Delay(sleep);

                        continue;
                    }

                    throw;
                }
            }
        }
Exemple #6
0
        public override void Register()
        {
            App.Singleton <CsvStore>().Alias <ICsvStore>().Alias("csv.store").Resolving((app, bind, obj) => {
                CsvStore store = obj as CsvStore;

                IConfigStore confStore = app.Make <IConfigStore>();

                string root = confStore.Get(typeof(CsvStore), "root", null);

                if (root != null)
                {
                    IEnv env      = app.Make <IEnv>();
                    IIOFactory io = app.Make <IIOFactory>();
                    IDisk disk    = io.Disk();

                                        #if UNITY_EDITOR
                    if (env.DebugLevel == DebugLevels.Auto || env.DebugLevel == DebugLevels.Dev)
                    {
                        disk.SetConfig(new Hashtable()
                        {
                            { "root", env.AssetPath + env.ResourcesNoBuildPath }
                        });
                    }
                                        #endif


                    store.SetDirctory(disk.Directory(root));
                }

                return(store);
            });;
        }
        private static string ConnectionString(IEnv env)
        {
            var instanceUrl  = env.CrmServiceUrl;
            var clientId     = env.CrmClientId;
            var clientSecret = env.CrmClientSecret;

            return($"AuthType=ClientSecret; url={instanceUrl}; ClientId={clientId}; ClientSecret={clientSecret}");
        }
 public CdsServiceClientWrapper(IEnv env)
 {
     // We don't want to try and connect to Dynamics when integration testing.
     if (!env.IsTest)
     {
         CdsServiceClient = new CdsServiceClient(ConnectionString(env));
         CdsServiceClient.MaxConnectionTimeout = TimeSpan.FromSeconds(30);
     }
 }
        public virtual void Init(IEnv enviroment, ICore core, Point position, int index)
        {
            Enviroment    = enviroment;
            Core          = core.Create(core);
            Position      = position;
            OrganismIndex = index;

            Config();
        }
Exemple #10
0
        public NumberExpr(NumberToken token, IEnv env)
            : base(env)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            base.Token = token;
        }
        static ServerEnv()
        {
#if BUILD_EC2
            selectedEnv = new EnvEC2();
#else
            CurrentEnv = new EnvLocalWithoutDB();
#endif

            Console.WriteLine("SelectedEnv : " + CurrentEnv);
        }
Exemple #12
0
        public StringExpr(StringToken token, IEnv env)
            : base(env)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            base.Token = token;
        }
Exemple #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="env"></param>
 /// <param name="epochs"></param>
 /// <param name="gamma"></param>
 public void PrepareLearn(IEnv env, int epochs = 300, float gamma = 0.0f, int forward = 256)
 {
     Env             = env;
     _epoches        = epochs;
     _gamma          = gamma;
     _forward        = forward;
     _actionKeys     = Env.RandomSeedKeys;
     _actionsNumber  = Env.ActionSapceCapacity;
     _featuresNumber = Env.InputDimensions.Product();
 }
Exemple #14
0
        public RedisRateLimitCounterStore(
            IEnv env,
            IMemoryCache memoryCache,
            ILogger <RedisRateLimitCounterStore> logger)
        {
            _logger           = logger;
            _memoryCacheStore = new MemoryCacheRateLimitCounterStore(memoryCache);
            var options = RedisConfiguration.ConfigurationOptions(env);

            _redis = ConnectionMultiplexer.Connect(options);
        }
 public CrmSyncJob(
     IEnv env,
     IStore store,
     ILogger <CrmSyncJob> logger,
     IMetricService metrics)
     : base(env)
 {
     _store   = store;
     _logger  = logger;
     _metrics = metrics;
 }
 public LocationSyncJob(
     IEnv env,
     GetIntoTeachingDbContext dbContext,
     ILogger <LocationSyncJob> logger,
     IMetricService metrics)
     : base(env)
 {
     _logger    = logger;
     _dbContext = dbContext;
     _metrics   = metrics;
 }
Exemple #17
0
 public ValueCont(
     ISList<IInsn> insns,
     ISList<IValue> stack,
     IEnv env,
     ISList<KeyValuePair<IValue, IValue>> winders
 )
 {
     Insns = insns;
     Stack = stack;
     Env = env;
     Winders = winders;
 }
Exemple #18
0
 public ValueClosure(
     IList<ValueSymbol> paras,
     ISList<IInsn> insns,
     IEnv env,
     SourceInfo info
 )
 {
     mParams = paras;
     mInsns = insns;
     mEnv = env;
     mInfo = info;
 }
Exemple #19
0
        public static void BuildProtobuf()
        {
            string savekey = "_" + typeof(ProtobufTool).ToString() + ".BuildProtobuf";

            IEnv env = App.Instance.Make <IEnv>();

            string protoPath = EditorUtility.OpenFilePanel("Choose .Proto File", UnityEngine.PlayerPrefs.GetString(savekey, UnityEngine.Application.dataPath), "proto");

            if (string.IsNullOrEmpty(protoPath))
            {
                return;
            }

            string saveTo = EditorUtility.SaveFilePanel("Save Proto File", protoPath, System.IO.Path.GetFileNameWithoutExtension(protoPath), "cs");

            if (string.IsNullOrEmpty(saveTo))
            {
                return;
            }

            UnityEngine.PlayerPrefs.SetString(savekey, System.IO.Path.GetDirectoryName(protoPath));

            string call = null;

            if (env.Platform == UnityEngine.RuntimePlatform.WindowsEditor)
            {
                call = GenToolPath + "protogen.exe";
            }
            else if (env.Platform == UnityEngine.RuntimePlatform.OSXEditor)
            {
                //call = "mono " + GenToolPath + "protogen.exe";
            }

            if (string.IsNullOrEmpty(call))
            {
                UnityEngine.Debug.Log("not support this platform to build"); return;
            }

            ProcessStartInfo start = new ProcessStartInfo(call);

            start.WindowStyle     = ProcessWindowStyle.Hidden;
            start.CreateNoWindow  = true;
            start.Arguments       = Arguments.Replace("{in}", protoPath).Replace("{out}", saveTo);
            start.CreateNoWindow  = false;
            start.ErrorDialog     = true;
            start.UseShellExecute = true;

            Process p = Process.Start(start);

            p.WaitForExit();
            UnityEngine.Debug.Log("protobuf build complete.");
            AssetDatabase.Refresh();
        }
Exemple #20
0
        /// <summary>
        /// Register an environment for a specific group and also set the selected environment
        /// within the environment context for that group.
        /// </summary>
        /// <param name="envGroup">e.g. "database"</param>
        /// <param name="ctx">Collection of environments for the <paramref name="envGroup"/></param>
        /// <param name="selectedEnvironment">The selected environment within the Environment context <paramref name="ctx"/></param>
        public static void Set(string envGroup, IEnv env)
        {
            if (string.IsNullOrEmpty(envGroup))
            {
                envGroup = Default;
            }

            _environments[envGroup] = env;
            if (envGroup == Default)
            {
                Env.Init(env);
            }
        }
Exemple #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="env"></param>
 public DQN(IEnv env)
 {
     //
     _env = env;
     //
     _actionsNumber = _env.ActionNum;
     //
     _featuresNumber = _env.FeatureNum.Product();
     //决策
     _actorNet = new DNet(_env.FeatureNum, _actionsNumber);
     //训练
     _criticNet = new DNet(_env.FeatureNum, _actionsNumber);
 }
Exemple #22
0
 public CrmSyncJob(
     IEnv env,
     IStore store,
     ILogger <CrmSyncJob> logger,
     IMetricService metrics,
     IAppSettings appSettings)
     : base(env)
 {
     _store       = store;
     _logger      = logger;
     _metrics     = metrics;
     _appSettings = appSettings;
 }
Exemple #23
0
        /// <summary>
        /// Select relevant patient series, Cdsi Logic Spec 4.1 Chapter 5.
        /// </summary>
        /// <param name="env"></param>
        /// <remarks>
        /// Note that other patient series' can be Add()ed to the processing data,
        /// for example to evaluate/forecast newborns.
        /// </remarks>
        public static IEnv SelectRelevantPatientSeries(this IEnv env)
        {
            // Todo: what if newborn who doesnt have an immunization history?
            var antigens = env.ImmunizationHistory.Select(x => x.AntigenName).Distinct();

            foreach (var antigen in antigens)
            {
                var sda = Data.Antigen[antigen];
                var rs  = sda.series.Where(x => x.IsRelevantSeries(env));
                env.RelevantPatientSeries = rs.Select(x => x.ToModel()).ToList();
            }
            return(env);
        }
Exemple #24
0
        /// <summary>
        /// Cdsi Logic Spec 4.1 Section 4-3
        /// </summary>
        /// <param name="env"></param>
        /// <returns></returns>
        public static IEnv OrganizeImmunizationHistory(this IEnv env)
        {
            var patient = env.Patient;

            var immunizationHistory = patient.AdministeredVaccineDoses
                                      .SelectMany(x => x.AsAntigenDoses())
                                      .OrderBy(x => x.AntigenName)
                                      .ThenBy(x => x.AdministeredDose.DateAdministered)
                                      .ToList();

            env.ImmunizationHistory = immunizationHistory;

            return(env);
        }
 public FormulaBuildingPipeline(IEnv env)
     : base(env)
 {
     Builders.Add(new ConstantExprBuilder(Env));
     Builders.Add(new GroupExprBuilder(Env));
     Builders.Add(new StringConcatExprBuilder(ApplyStringConcatOptimization, Env)); // must be before `MathExprBuilder`
     Builders.Add(new MathExprBuilder(ApplyStringConcatOptimization, Env));
     Builders.Add(new PlusOrMinusExprBuilder(Env));
     Builders.Add(new ConditionalExprBuilder(Env));
     Builders.Add(new NegationExprBuilder(Env));
     Builders.Add(new LogicalExprBuilder(Env));
     Builders.Add(new ArrayExprBuilder(Env));
     Builders.Add(new FuncExprBuilder(Env));
 }
Exemple #26
0
 public UpsertCandidateJob(
     IEnv env,
     ICrmService crm,
     INotifyService notifyService,
     IPerformContextAdapter contextAdapter,
     IMetricService metrics,
     ILogger <UpsertCandidateJob> logger)
     : base(env)
 {
     _crm            = crm;
     _notifyService  = notifyService;
     _contextAdapter = contextAdapter;
     _metrics        = metrics;
     _logger         = logger;
 }
Exemple #27
0
        public static IEnv EvaluatePatientSeries(this IEnv env)
        {
            foreach (IPatientSeries patientSeries in env.RelevantPatientSeries)
            {
                var evaluator = new SeriesEvaluator()
                {
                    PatientSeries = patientSeries,
                    AntigenDoses  = env.ImmunizationHistory
                };

                evaluator.Evaluate();
            }

            return(env);
        }
Exemple #28
0
 public MagicLinkTokenGenerationJob(
     IEnv env,
     IBackgroundJobClient jobClient,
     ICandidateMagicLinkTokenService magicLinkTokenService,
     ICrmService crm,
     ILogger <MagicLinkTokenGenerationJob> logger,
     IMetricService metrics)
     : base(env)
 {
     _jobClient             = jobClient;
     _magicLinkTokenService = magicLinkTokenService;
     _crm     = crm;
     _logger  = logger;
     _metrics = metrics;
 }
 public OperationsController(
     ICrmService crm,
     IStore store,
     INotifyService notifyService,
     IHangfireService hangfire,
     IRedisService redis,
     IEnv env)
 {
     _store         = store;
     _crm           = crm;
     _notifyService = notifyService;
     _hangfire      = hangfire;
     _redis         = redis;
     _env           = env;
 }
Exemple #30
0
        public CalculationService()
        {
            _tokenizer = new FormulaTokenizer();

            var env          = new FormulaEnv();
            var executingAsm = Assembly.GetExecutingAssembly();

            env.DiscoverFuncsFromAssembly(executingAsm);                 // load local functions
            foreach (var name in executingAsm.GetReferencedAssemblies()) // load third-party functions
            {
                env.DiscoverFuncsFromAssembly(Assembly.Load(name.ToString()));
            }
            _env = env;

            _pipeline = new FormulaBuildingPipeline(_env);
        }
        public static ConfigurationOptions ConfigurationOptions(IEnv env)
        {
            var options = new JsonSerializerOptions()
            {
                PropertyNameCaseInsensitive = true
            };
            var vcap        = JsonSerializer.Deserialize <VcapServices>(env.VcapServices, options);
            var redis       = vcap.Redis.First();
            var credentials = redis.Credentials;

            return(new ConfigurationOptions()
            {
                EndPoints = { { credentials.Host, credentials.Port } },
                Password = credentials.Password,
                AbortOnConnectFail = false,
                Ssl = credentials.TlsEnabled,
            });
        }
Exemple #32
0
        public static void BuildProtobuf()
        {
            IEnv env = App.Instance.Make <IEnv>();

            string protoPath = EditorUtility.OpenFilePanel("Choose .Proto File", UnityEngine.Application.dataPath, "proto");

            if (string.IsNullOrEmpty(protoPath))
            {
                return;
            }

            string saveTo = EditorUtility.SaveFilePanel("Save Proto File", protoPath, System.IO.Path.GetFileNameWithoutExtension(protoPath), "cs");

            if (string.IsNullOrEmpty(saveTo))
            {
                return;
            }

            string call = null;

            if (env.Platform == UnityEngine.RuntimePlatform.WindowsEditor)
            {
                call = GenToolPath + "protogen.exe";
            }
            else if (env.Platform == UnityEngine.RuntimePlatform.OSXEditor)
            {
                //call = "mono " + GenToolPath + "protogen.exe";
            }

            if (string.IsNullOrEmpty(call))
            {
                UnityEngine.Debug.Log("not support this platform to build"); return;
            }

            ProcessStartInfo start = new ProcessStartInfo(call);

            start.Arguments       = Arguments.Replace("{in}", protoPath).Replace("{out}", saveTo);
            start.CreateNoWindow  = false;
            start.ErrorDialog     = true;
            start.UseShellExecute = true;

            Process p = Process.Start(start);
        }
Exemple #33
0
 public EnvLocal(IEnv outerEnv)
 {
     mInnerEnv = new EnvGlobal();
     OuterEnv = outerEnv;
 }
Exemple #34
0
 public Interpreter(IEnv env)
 {
     mEnv = env;
 }