void channel_OfferAcceptedEvent(object sender, EventArgs e) { if (sender == AiChannel) { Status.LastAcceptedOffer = Status.HumanStatus.Offer; } else { Status.LastAcceptedOffer = Status.AiStatus.Offer; } Status.AiStatus.Signed = false; Status.HumanStatus.Signed = false; Status.AcceptedOfferSide = (INegotiationChannel)sender; SideConfig side = (Status.AcceptedOfferSide == AiChannel) ? AiConfig : HumanConfig; this.Actions.Add(new NegotiationActionModel() { RemainingTime = Status.RemainingTime, Role = side.Side, Type = NegotiationActionType.AcceptOffer }); NegotiationManager.SaveOfferAccepted(this, side); ThreadPool.QueueUserWorkItem(x => { GetOtherChannel(Status.AcceptedOfferSide).OpponentAcceptedOffer(); }); }
public void Initialize(NegotiationDomain domain, SideConfig strategyConfig, String opponentSide, INegotiationClient client) { Client = client; client.OfferReceivedEvent += client_OfferReceivedEvent; client.NegotiationEndedEvent += client_NegotiationEndedEvent; }
public override void Initialize(Negotiation.Models.NegotiationDomain domain, Negotiation.Models.SideConfig strategyConfig, string opponentSide, Negotiation.Models.INegotiationClient client) { base.Initialize(domain, strategyConfig, opponentSide, client); m_BestCombinedUtilityOffers = new Dictionary <string, OfferUtility>(BestCombinedUtilityOffers); m_BestFScoreUtilityOffers = new Dictionary <string, OfferUtility>(BestFScoreUtilityOffers); m_typeUtilities = Domain.OwnerVariantDict[OpponentSide].Keys.ToDictionary(k => k, k => 0.0); }
public virtual void Initialize(NegotiationDomain domain, SideConfig strategyConfig, String opponentSide, INegotiationClient client) { Domain = domain; StrategyConfig = strategyConfig; Client = client; OpponentSide = opponentSide; Client.NegotiationStartedEvent += OnNegotiationStartedEvent; Client.NegotiationEndedEvent += OnNegotiationEndedEvent; Client.OfferReceivedEvent += OnOfferReceivedEventInner; Client.TimePassedEvent += OnTimePassedEventInner; Client.OpponentAcceptedOfferEvent += OnOpponentAcceptedOfferEvent; CalculateOffers(); }
public override void Initialize(Negotiation.Models.NegotiationDomain domain, Negotiation.Models.SideConfig strategyConfig, string opponentSide, Negotiation.Models.INegotiationClient client) { base.Initialize(domain, strategyConfig, opponentSide, client); m_BestCombinedUtilityOffers = new Dictionary <string, OfferUtility>(BestCombinedUtilityOffers); m_BestFScoreUtilityOffers = new Dictionary <string, OfferUtility>(BestFScoreUtilityOffers); var opponentTypes = domain.OwnerVariantDict[opponentSide].Keys; m_typeProbabilites = opponentTypes.ToDictionary(k => k, x => (1.0 / opponentTypes.Count)); var utilitySums = opponentTypes.ToDictionary(k => k, k => AllOptions.Values.Sum(x => x.UtilityDataDict[k].OpponentUtility)); m_offerProbabilities = AllOptions.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.UtilityDataDict.ToDictionary(kvp2 => kvp2.Key, kvp2 => kvp2.Value.OpponentUtility / utilitySums[kvp2.Key])); }
private static void SaveAction(NegotiationEngine engine, SideConfig side, NegotiationActionType type, String value = "") { NegotiationContainer cont = new NegotiationContainer(); var game = cont.GameSet.Find(engine.NegotiationId); var user = game.Users.First(x => x.Type == side.Type); cont.NegotiationActionSet.Add(new NegotiationAction() { GameId = engine.NegotiationId, Type = type, User = user, RemainingTime = engine.Status.RemainingTime, UserId = user.Id, Value = value }); cont.SaveChanges(); }
void channel_OfferRejectedEvent(object sender, EventArgs e) { SideConfig side = (sender == AiChannel) ? AiConfig : HumanConfig; this.Actions.Add(new NegotiationActionModel() { RemainingTime = Status.RemainingTime, Role = side.Side, Type = NegotiationActionType.RejectOffer }); NegotiationManager.SaveOfferRejected(this, side); ThreadPool.QueueUserWorkItem(x => { GetOtherChannel((INegotiationChannel)sender).OpponentRejectedOffer(); }); }
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); }
public NegotiationSideDescription GetSideDescription(SideConfig config) { return OwnerVariantDict[config.Side][config.Variant]; }
internal static void SaveOfferRejected(NegotiationEngine engine, SideConfig side) { SaveAction(engine, side, NegotiationActionType.RejectOffer); }
internal static void SaveOptOut(NegotiationEngine engine, SideConfig side) { SaveAction(engine, side, NegotiationActionType.Optout); }
internal static void SaveAgreementSigned(NegotiationEngine engine, SideConfig side) { SaveAction(engine, side, NegotiationActionType.Sign); }
internal static void SaveNewOffer(NegotiationEngine engine, SideConfig side, string negotiationOffer) { SaveAction(engine, side, NegotiationActionType.MakeOffer, negotiationOffer); }
public int CalculateOptoutScore(SideConfig config, int roundsPassed) { var variant = OwnerVariantDict[config.Side][config.Variant]; return variant.Optout + variant.TimeEffect * roundsPassed; }
public int CalculateOptoutScore(SideConfig config, int roundsPassed) { var variant = OwnerVariantDict[config.Side][config.Variant]; return(variant.Optout + variant.TimeEffect * roundsPassed); }
private int CalculateAcceptScore(SideConfig config, NegotiationOffer offer) { var variant = Domain.OwnerVariantDict[config.Side][config.Variant]; return(offer.Offers.Sum(x => variant.Topics[x.Key].Options[x.Value].Score) + variant.TimeEffect * Domain.RoundsPassed(Status.RemainingTime)); }
public NegotiationSideDescription GetSideDescription(SideConfig config) { return(OwnerVariantDict[config.Side][config.Variant]); }
public int CalculateTimeoutScore(SideConfig config) { var variant = OwnerVariantDict[config.Side][config.Variant]; return variant.Reservation + variant.TimeEffect * NumberOfRounds; }
protected double CalculateUtility(IEnumerable<KeyValuePair<String, String>> offer, SideConfig config) { var sideDesc = Domain.GetSideDescription(config); return offer.Aggregate(0.0, (sum, x) => sum + sideDesc.Topics[x.Key].Options[x.Value].Score); }
public int CalculateTimeoutScore(SideConfig config) { var variant = OwnerVariantDict[config.Side][config.Variant]; return(variant.Reservation + variant.TimeEffect * NumberOfRounds); }
public int CalculateOptoutScore(SideConfig config, TimeSpan remainingTime) { return(CalculateOptoutScore(config, RoundsPassed(remainingTime))); }
public int CalculateOptoutScore(SideConfig config, TimeSpan remainingTime) { return CalculateOptoutScore(config, RoundsPassed(remainingTime)); }