Ejemplo n.º 1
0
        internal static IAgentStrategy GetStrategy(int strategyId, out String strategyName)
        {
            NegotiationContainer cont = new NegotiationContainer();
            var strat = cont.StrategySet.Find(strategyId);

            String dllPath = HttpContext.Current.Server.MapPath(strat.DllPath);
            String dllDir  = System.IO.Path.GetDirectoryName(dllPath);

            Assembly assembly = Assembly.LoadFile(dllPath);

            Type           type    = assembly.GetTypes().First(x => x.GetInterface("IAgentStrategy") != null);
            IAgentStrategy example = assembly.CreateInstance(type.FullName) as IAgentStrategy;

            strategyName = strat.StrategyName;

            return(example);
        }
Ejemplo n.º 2
0
        public NegotiationEngine(
            String negotiationId,
            NegotiationDomain domain,
            PreNegotiationQuestionnaireViewModel userData,
            SideConfig humanConfig,
            AiConfig aiConfig)
        {
            NegotiationId = negotiationId;
            Domain        = domain;
            HumanChannel  = new LocalNegotiationChannel();
            AiChannel     = new LocalNegotiationChannel();
            HumanConfig   = humanConfig;
            AiConfig      = aiConfig;

            Status = new NegotiationStatus()
            {
                RemainingTime = TimeSpan.FromSeconds(domain.NumberOfRounds * domain.RoundLength.TotalSeconds),
                HumanStatus   = new SideStatus()
                {
                    Offer = EmptyOffer()
                },
                AiStatus = new SideStatus()
                {
                    Offer = EmptyOffer()
                },
                LastAcceptedOffer = EmptyOffer()
            };

            Actions = new List <NegotiationActionModel>();

            String         strategyName;
            IAgentStrategy strat = NegotiationManager.GetStrategy(aiConfig.StrategyId, out strategyName);

            strat.Initialize(domain, aiConfig, humanConfig.Side, AiChannel);

            TimeSpan defaultInterval = TimeSpan.FromSeconds(1);

            UpdateInterval = defaultInterval < strat.MinimumUpdateTime ? defaultInterval : strat.MinimumUpdateTime;

            StrategyName = strategyName;

            RegisterChannel(HumanChannel);
            RegisterChannel(AiChannel);
        }