public Direto2(ElicitationParameters p, IFormPrincipal ifPrincipal)
        {
            InitializeComponent();
            this.ifPrincipal = ifPrincipal;
            this.question    = this.ifPrincipal.getQuestion();
            this.p           = p.getClone();

            this.p.max = p.max;
            this.p.min = p.min;
            this.upperOfLowerInterval = p.upperOfLowerInterval;
            this.lowerOfUpperInterval = p.lowerOfUpperInterval;
            this.p.center             = p.center;
            this.p.cred         = p.cred;
            this.p.index        = p.index;
            this.p.iteracao     = p.iteracao + 1;
            this.times          = p.times;
            this.answers        = p.answers;
            this.statistics     = p.statistics;
            this.W              = p.W;
            this.x              = p.x;
            this.k              = p.k;
            this.numberInterval = k;
            this.intervalSize   = (p.min + p.max) / p.k;

            initMethod2();
            this.loadConfigMethodForVariable();

            this.configChartSeriesDirect(p.min, p.max, p.k);
        }
        override protected IMethod updateMethod()
        {
            ElicitationParameters par = p.getClone();

            try {
                par.cred = 0.5;
                string resposta = this.p.center + "";
                par.answers = this.answers;
                par.answers.Add(resposta);
                par.x = (Double[])this.x.Clone();

                par.times = this.times;

                this.statistics.Add(Convert.ToDouble(lista[lista.Length - 8]));
                this.statistics.Add(Convert.ToDouble(lista[lista.Length - 7]));
                this.statistics.Add(Convert.ToDouble(lista[lista.Length - 6]));
                this.statistics.Add(Convert.ToDouble(lista[lista.Length - 5]));
                par.statistics = statistics;
                par.min        = this.p.min;
                par.center     = this.p.center;
                par.max        = this.p.max;
                par.iteracao   = this.p.iteracao;
                par.index++;

                Bisection bisection = new Bisection(par, this.ifPrincipal);

                return(bisection);
            } catch (Exception ex) {
                throw;
            }
        }
        virtual public ElicitationParameters getStatistics()
        {
            ElicitationParameters par = this.p.getClone();

            try{
                par.media     = double.Parse(this.MC_histogram.LB_Mean.Text);
                par.mediana   = double.Parse(this.MC_histogram.LB_Median.Text);
                par.moda      = double.Parse(this.MC_histogram.LB_Mode.Text);
                par.variancia = double.Parse(this.MC_histogram.LB_Var.Text);
            } catch { };
            return(par);
        }
        public Bisection(ElicitationParameters p, IFormPrincipal ifPrincipal) : base()
        {
            InitializeComponent();
            this.ifPrincipal = ifPrincipal;
            this.question    = this.ifPrincipal.getQuestion();
            this.p           = p.getClone();

            //this.upperOfLowerInterval = p.upperOfLowerInterval;
            //this.lowerOfUpperInterval = p.lowerOfUpperInterval;
            this.lowerOfUpperInterval = new List <double> ();
            this.upperOfLowerInterval = new List <double> ();
            //this.center = p.center;
            this.p.cred     = p.cred;
            this.p.index    = p.index;
            this.p.iteracao = p.iteracao + 1;
            this.times      = p.times;
            this.answers    = p.answers;
            this.statistics = p.statistics;
            this.x          = p.x;

            if (ifPrincipal.isTrainingPhase())  //Permitir apenas uma iteração caso seja treinamento.
            //List<double> lines = new List<double>();
            //this.ifPrincipal.markChoosableAreaChartSeries(lines);
            {
                if (this.p.iteracao > 1)
                {
                    this.RB_semPreferencia.Enabled = false;
                    this.TR_mdSearch.Enabled       = false;
                }
            }
            else
            {
                if (this.p.iteracao >= 4)
                {
                    this.RB_semPreferencia.Enabled = false;
                    this.TR_mdSearch.Enabled       = false;
                }
            }

            this.intervals = this.x.ToList();

            showMainPanel(p.min, p.center, p.max, this.p.cred, this.p.index);
            this.loadConfigMethodForVariable();

            List <double> lines = new List <double>();

            lines.Add(this.p.min);
            lines.Add(this.p.center);
            lines.Add(this.p.max);
            this.ifPrincipal.markChoosableAreaChartSeries(lines);
        }
Beispiel #5
0
        //override public int

        override protected IMethod updateMethod()
        {
            double  cred;
            Boolean verificar = Double.TryParse(TB_Credibilidade.Text, out cred);

            if (!verificar)
            {
                throw new Exception(DefaultConfig.ST_TXT_VALUES_TYPE_WROTE);
            }
            if (cred < .5)
            {
                throw new Exception("A sua credibilidade dever estar dentro do seguinte intervalo [.5 , 1].");
            }
            if (!(RB_MidleMax.Checked == true || RB_MinMidle.Checked == true))
            {
                throw new Exception(DefaultConfig.ST_TXT_CHANGE_ALTERNATIVE_CREDIBILITY);
            }
            ElicitationParameters par = p.getClone();
            //ifPrincipal.getWatch().Stop();
            //this.p.timeConsumption = ifPrincipal.getWatch().ElapsedMilliseconds;//medir o tempo da iteração
            //ifPrincipal.getWatch().Restart();
            string resposta = this.RB_MinMidle.Text.Substring(2, RB_MinMidle.Text.Length - 9).Replace(',', ';');

            par.creds.Add(cred);
            par.cred   = cred;
            par.center = (this.p.min + this.p.max) / 2;
            par.answers.Add(resposta);
            par.times.Add(this.p.timeConsumption / 1000);//Armazenar nas listas os valores do tempo consumido e das respostas
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 8]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 7]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 6]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 5]));
            par.iteracao += 1;
            par.x         = this.x;

            //this.p.W = new double[4]{cred,1-cred};
            int    index = 0;
            double newMin = this.p.min, newMax = this.p.center;

            if (this.RB_MidleMax.Checked == true)
            {
                //RB_MidleMax.Checked = false;
                index    = 1;
                resposta = this.RB_MidleMax.Text.Substring(2, RB_MidleMax.Text.Length - 6).Replace(',', ';');
            }

            par.index = index;

            return(new Firmino(par, this.ifPrincipal));
        }
Beispiel #6
0
        //private Variable variable;

        //Construtor
        public Firmino(ElicitationParameters p, IFormPrincipal ifPrincipal)
        {
            this.ifPrincipal = ifPrincipal;
            this.question    = this.ifPrincipal.getQuestion();
            this.p           = p.getClone();
            //Este if indica que o método só fará três interações.
            if (p.iteracao >= 3)
            {
                this.BT_Update.Enabled = false;
            }
            else
            {
                this.BT_Update.Enabled = true;
            }

            showMainPanel(p.min, p.center, p.max, p.cred, p.index);
            this.loadConfigMethodForVariable();
        }
Beispiel #7
0
        override protected IMethod updateMethod()
        {
            double  cred;
            Boolean verificar = Double.TryParse(TB_Credibilidade.Text, out cred);

            if (!verificar)
            {
                throw new Exception(DefaultConfig.ST_TXT_VALUES_TYPE_WROTE);
            }
            if (cred < .5)
            {
                throw new Exception("A sua credibilidade dever estar dentro do seguinte intervalo [.5 , 1].");
            }
            if (!(RB_MidleMax.Checked == true || RB_MinMidle.Checked == true))
            {
                throw new Exception(DefaultConfig.ST_TXT_CHANGE_ALTERNATIVE_CREDIBILITY);
            }

            ElicitationParameters par = p.getClone();

            int    index    = 0;
            string resposta = this.RB_MinMidle.Text.Substring(2, RB_MinMidle.Text.Length - 9).Replace(',', ';');

            if (this.RB_MidleMax.Checked == true)
            {
                index    = 1;
                resposta = this.RB_MidleMax.Text.Substring(2, RB_MidleMax.Text.Length - 6).Replace(',', ';');
            }
            par.answers.Add(resposta);

            par.creds.Add(cred);
            par.cred   = cred;
            par.center = (par.min + par.max) / 2;
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 8]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 7]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 6]));
            par.statistics.Add(Convert.ToDouble(lista[lista.Length - 5]));
            par.iteracao += 1;
            par.x         = this.x;

            par.index = index;

            return(new Firmino(par, this.ifPrincipal));
        }
Beispiel #8
0
        private void BT_bissection_firmino_avancar_Click(object sender, EventArgs e)
        {
            new TimeEvent(this.ifPrincipal.getQuestion(), TimeEvent.EventType.LEAVE_FIRST_PANEL_OF_ELICITATION, access.process);

            ElicitationParameters p = new ElicitationParameters();

            try {
                p.max = Convert.ToDouble(TB_ValorMaximo.Text);
                p.min = Convert.ToDouble(TB_ValorMinimo.Text);
                if (p.min < p.max)
                {
                    verificar = true;
                }
                else
                {
                    ifPrincipal.DisplayMessage(DefaultConfig.ST_TXT_VALUES_IRREGULARS_MINMAX, true);
                }
            } catch {
                ifPrincipal.DisplayMessage(DefaultConfig.ST_TXT_VALUES_TYPE_WROTE, true);
            }

            if (verificar == true)
            {
                string resposta = TB_ValorMinimo.Text + ';' + TB_ValorMaximo.Text;

                p.center = (p.max + p.min) / 2;
                p.index  = -1;
                //p.times.Add(timeComsumption / 1000);
                p.answers.Add(resposta);
                p.creds.Add(0.0);//Passando credibilidade nula para não construir outra condicional no momento do back
                //statistics.Add(0);//passando estatistica nula para não desagrupar as respostas e estatisticas
                p.statistics.AddRange(new double[4] {
                    0, 0, 0, 0
                });
                p.W = new double[2] {
                    0, 0
                };

                this.ifPrincipal.addNewIteraction(currentMethod);
            }
        }
Beispiel #9
0
        private void BT_Avançar_Click(object sender, EventArgs e)
        {
            new TimeEvent(this.ifPrincipal.getQuestion(), TimeEvent.EventType.LEAVE_FIRST_PANEL_OF_ELICITATION, access.process);
            ElicitationParameters par = new ElicitationParameters();

            try {
                par.min     = Convert.ToDouble(TB_ValorMinimo.Text);
                par.max     = Convert.ToDouble(TB_ValorMaximo.Text);
                par.rootMin = par.min;
                par.rootMax = par.max;
                k           = int.Parse(TB_Intervals.Text);
                par.k       = k;
                if (par.min < par.max)
                {
                    verificar = true;
                }
                else
                {
                    ifPrincipal.DisplayMessage(DefaultConfig.ST_TXT_VALUES_IRREGULARS_MINMAX, true);
                    verificar = false;
                }
            } catch {
                throw new Exception(DefaultConfig.ST_TXT_VALUES_TYPE_WROTE);
            }
            try {
                if (verificar == true)
                {
                    par.index  = -1;
                    par.center = (par.min + par.max) / 2;

                    if (elicitationMethod == ElicitationMethod.Direto)
                    {
                        double   intervalSize = (par.max - par.min) / k;
                        double[] x            = new double[k + 1]; //grid
                        double[] W            = new double[k + 1]; //credibilities
                        x[0] = par.min; x[k] = par.max;
                        W[0] = 0; W[k] = (1.0 / k);                //W[0] equal Fx[0], W[1] is the credibility assigned to the first interval, and so on
                        for (int i = 1; i < k; i++)
                        {
                            x[i] = x[i - 1] + intervalSize;
                            W[i] = (1.0 / k);
                        }
                        par.W = W;
                        par.x = x;

                        currentMethod = (IMethod) new Direto2(par, this.ifPrincipal);
                    }
                    else if (elicitationMethod == ElicitationMethod.Bissecao)
                    {
                        par.x         = new double[] { par.min, par.max };
                        currentMethod = (IMethod) new Bisection(par, this.ifPrincipal);
                    }
                    else if (elicitationMethod == ElicitationMethod.Firmino)
                    {
                        currentMethod = (IMethod) new Firmino(par, this.ifPrincipal);
                    }
                    currentMethod.sendRerefence(this);

                    this.ifPrincipal.addNewIteraction(currentMethod); //Mostra na tela os campos para por os intervalos.
                }
            } catch (Exception exc) {
                ifPrincipal.DisplayMessage(exc.StackTrace, true);
            }
        }
Beispiel #10
0
        private void BT_Avançar_Click(object sender, EventArgs e)
        {
            new TimeEvent(this.ifPrincipal.getQuestion(), TimeEvent.EventType.LEAVE_FIRST_PANEL_OF_ELICITATION, access.process);
            ifPrincipal.getWatch().Stop();
            this.timeComsumption = ifPrincipal.getWatch().ElapsedMilliseconds;
            ifPrincipal.getWatch().Reset();
            ElicitationParameters p = new ElicitationParameters();

            try
            {
                p.max = Convert.ToDouble(TB_ValorMaximo.Text);
                p.min = Convert.ToDouble(TB_ValorMinimo.Text);
                if (p.min < p.max || p.min == p.max)
                {
                    verificar = true;
                }
                else
                {
                    ifPrincipal.DisplayMessage(DefaultConfig.ST_TXT_VALUES_IRREGULARS_MINMAX, true);
                }
            }
            catch
            {
                ifPrincipal.DisplayMessage(DefaultConfig.ST_TXT_VALUES_TYPE_WROTE, true);
            }

            if (verificar == true)
            {
                Firmino   firmino;
                Bisection bisection;
                Panel     panel1 = null;

                string resposta = TB_ValorMinimo.Text + ';' + TB_ValorMaximo.Text;

                p.center = (p.max + p.min) / 2;
                p.index  = -1;
                p.times.Add(timeComsumption / 1000);
                p.answers.Add(resposta);
                p.creds.Add(0.0);//Passando credibilidade nula para não construir outra condicional no momento do back
                //statistics.Add(0);//passando estatistica nula para não desagrupar as respostas e estatisticas
                p.statistics.AddRange(new double[4] {
                    0, 0, 0, 0
                });
                p.W = new double[2] {
                    0, 0
                };

                if (this.METHOD.Equals(Engine.EngineInterface.FIRMINO))
                {
                    //firmino = new Firmino("", p.min, p.center, p.max, 1, -1, 0, p.times,
                    //    p.answers, p.statistics, p.creds, this.ifPrincipal);
                    firmino = new Firmino(p, this.ifPrincipal);
                    //Cria o objeto firmino chamando a classe Firmino. Here thexpert has chose [min, max] with credib=1.0
                    //firmino.ReceberReferenciadoFrom0(this);//Metodo que faz com que seja possivel o form0 chamar ele proprio
                    panel1        = firmino.panel1;
                    currentMethod = (IMethod)firmino;
                }
                else if (this.METHOD.Equals(Engine.EngineInterface.BISECTION))
                {
                    bisection = new Bisection(p, this.ifPrincipal);
                    //bisection = new Bisection("", p.min, p.center, p.max, 1, -1, 0, p.times,
                    //    p.answers, p.statistics, this.ifPrincipal);//Cria o objeto firmino chamando a classe Firmino. Here thexpert has chose [min, max] with credib=1.0
                    //bisection.ReceberReferenciadoFrom0(this);//Metodo que faz com que seja possivel o form0 chamar ele proprio
                    //panel1 = bisection.mainPanel;
                    currentMethod = (IMethod)bisection;
                }

                this.ifPrincipal.addNewIteraction(currentMethod);
            }
        }