예제 #1
0
        //is the negotiator between agent 5 and agent 2
        public double negotiateAG5AG2(double kW, double pricePerHour)
        {
            Random randy = new Random();

            double µAg5 = ag2_.consumptionCenteralHeaterMin() * pricePerHour;
            double µAg2 = ag2_.consumptionCenteralHeaterMax() * pricePerHour;

            double rand = randy.NextDouble();

            double sigmoidAg5 = 1 / (1 + Math.Pow(Math.E, ((kW - µAg5) / slack_)));            // buy
            double sigmoidAg2 = 1 - (1 / ((1 + Math.Pow(Math.E, (kW - µAg5))) / ag2_.Slack_)); // sell

            if (rand > sigmoidAg5 && rand > sigmoidAg2)
            {
                return(kW);
            }
            //if kW is greater than µAg1 then they have not reached an agreement, then kW = µAg5 so that it starts all over again
            else if (kW > µAg2)
            {
                return(kW = µAg5);
            }
            else
            {
                slack_ += 0.36;
                //ag2_.Slack += 0.36;
            }
            return(negotiateAG5AG2(kW + 1, pricePerHour));
        }
예제 #2
0
        //to contiuously update the label deligate is used
        private void agentsLabels(int i, int j, bool state)
        {
            LabelDayAgent1.Invoke((MethodInvoker)(() => LabelDayAgent1.Text = "Day: " + i));
            LabelHourAgent1.Invoke((MethodInvoker)(() => LabelHourAgent1.Text = "Hour: " + j));
            LabelStateAgent1.Invoke((MethodInvoker)(() => LabelStateAgent1.Text = "State: " + currentStateIs(state)));
            LabelConsumptionHeatedFloorAgent1.Invoke((MethodInvoker)(() => LabelConsumptionHeatedFloorAgent1.Text = "Consumption heated floor: " + ag1_.consumptionHeatedFloorMax() + " kW/h"));
            LabelConsumptionBoilerAgent1.Invoke((MethodInvoker)(() => LabelConsumptionBoilerAgent1.Text = "Consumption boiler: " + ag1_.consumptionBoiler() + " kW/h"));

            LabelDayAgent2.Invoke((MethodInvoker)(() => LabelDayAgent2.Text = "Day: " + i));
            LabelHourAgent2.Invoke((MethodInvoker)(() => LabelHourAgent2.Text = "Hour: " + j));
            LabelStateAgent2.Invoke((MethodInvoker)(() => LabelStateAgent2.Text = "State: " + currentStateIs(state)));
            LabelConsumptionCentralHeatingAgent2.Invoke((MethodInvoker)(() => LabelConsumptionCentralHeatingAgent2.Text = "Consumption central heating: " + ag2_.consumptionCenteralHeaterMax() + " kW/h"));

            LabelDayAgent3.Invoke((MethodInvoker)(() => LabelDayAgent3.Text = "Day: " + i));
            LabelHourAgent3.Invoke((MethodInvoker)(() => LabelHourAgent3.Text = "Hour: " + j));
            LabelStateAgent3.Invoke((MethodInvoker)(() => LabelStateAgent3.Text = "State: " + currentStateIs(state)));
            LabelBatteryLevelAgent3.Invoke((MethodInvoker)(() => LabelBatteryLevelAgent3.Text = "Battery level: " + ag3_.batteryLevel() + " kW"));

            LabelDayAgent4.Invoke((MethodInvoker)(() => LabelDayAgent4.Text = "Day: " + i));
            LabelHourAgent4.Invoke((MethodInvoker)(() => LabelHourAgent4.Text = "Hour: " + j));
            LabelStateAgent4.Invoke((MethodInvoker)(() => LabelStateAgent4.Text = "State: " + currentStateIs(state)));

            LabelDayAgent5.Invoke((MethodInvoker)(() => LabelDayAgent5.Text = "Day: " + i));
            LabelHourAgent5.Invoke((MethodInvoker)(() => LabelHourAgent5.Text = "Hour: " + j));
            LabelStateAgent5.Invoke((MethodInvoker)(() => LabelStateAgent5.Text = "State: " + currentStateIs(state)));
            LabelSolarPanelAgent5.Invoke((MethodInvoker)(() => LabelSolarPanelAgent5.Text = "Solar Panel: " + ag5_.solarPanel(j) + " kW/h"));
            LabelActionAgent5.Invoke((MethodInvoker)(() => LabelActionAgent5.Text = "Action cost: " + ag5_.getBuyNOK(j) + " credit"));
        }