コード例 #1
0
ファイル: Form1.cs プロジェクト: SW2grupoA/MBCIF
        public void cargarEjemploColectivo()
        {
            Elemento gananciaColectivo = new Elemento("Ganancia colectivo", 2000);
            Elemento gananciaMicro = new Elemento("Ganancia microbus", 0);
            Elemento precioPasajeColectivo = new Elemento("Precio pasaje colectivo", 200);
            Elemento precioPasajeMicro = new Elemento("Precio pasaje micro", 150);
            Elemento cantidadTotalUsuarios = new Elemento("Cantidad total de usuarios", 0);
            Elemento precioPetroleo = new Elemento("Precio petróleo", 140);
            Elemento precioBencina = new Elemento("Precio bencina", 0);
            Elemento gananciaDiariaColectivero = new Elemento("Ganancia diaria colectivero", 0);

            Nivel primerNivel = new Nivel("Primer nivel");
            primerNivel.agregarElemento(gananciaDiariaColectivero);
            primerNivel.agregarElemento(new Elemento("Ganancia diaria conductor microbús", 0));
            primerNivel.agregarElemento(gananciaColectivo);
            primerNivel.agregarElemento(gananciaMicro);
            primerNivel.agregarElemento(new Elemento("Número de vueltas al día colectivo", 20));
            primerNivel.agregarElemento(new Elemento("Número de vueltas al día microbús", 10));
            primerNivel.agregarElemento(precioPasajeColectivo);
            primerNivel.agregarElemento(precioPasajeMicro);
            primerNivel.agregarElemento(cantidadTotalUsuarios);

            primerNivel.agregarRelacion(2, 0, new relacion("x", new regla(1)));
            primerNivel.agregarRelacion(3, 1, new relacion("x", new regla(1)));
            primerNivel.agregarRelacion(4, 0, new relacion("y*x", new regla(1)));
            primerNivel.agregarRelacion(5, 1, new relacion("y*x", new regla(1)));

            Nivel nivelColectivo = new Nivel("Colectivo");

            Elemento demandaColectivo = new Elemento("Demanda de clientes colectivo", 40);

            nivelColectivo.agregarElemento(precioPasajeColectivo);
            nivelColectivo.agregarElemento(precioBencina);
            nivelColectivo.agregarElemento(demandaColectivo);
            nivelColectivo.agregarElemento(gananciaColectivo);
            nivelColectivo.agregarElemento(new Elemento("Distancia recorrida", 1000));
            nivelColectivo.agregarElemento(new Elemento("Bencina ocupada", 10));
            nivelColectivo.agregarElemento(new Elemento("Perdida por desgaste", 0));
            nivelColectivo.agregarElemento(new Elemento("Perdida por reparacion", 0));
            nivelColectivo.agregarElemento(new Elemento("Desgaste (Kilometraje acumulado)", 0));

            //Relaciones
            //nivelColectivo.agregarRelacion(1, 3, new relacion("x*(6/13)", new regla(1)));
            nivelColectivo.agregarRelacion(0, 3, new relacion("x", new regla(1)));
            nivelColectivo.agregarRelacion(0, 2, new relacion("logx*(x/35)", new regla(1)));

            nivelColectivo.agregarRelacion(1, 0, new relacion("x*(6/7)", new regla(1)));
            nivelColectivo.agregarRelacion(1, 5, new relacion("x", new regla(1)));

            nivelColectivo.agregarRelacion(2, 3, new relacion("y*x", new regla(1)));
            nivelColectivo.agregarRelacion(2, 4, new relacion("x*10", new regla(1)));

            nivelColectivo.agregarRelacion(4, 5, new relacion("y*(x/14)", new regla(1)));
            nivelColectivo.agregarRelacion(4, 8, new relacion("y+x", new regla(1)));

            nivelColectivo.agregarRelacion(5, 3, new relacion("y-x", new regla(1)));

            nivelColectivo.agregarRelacion(6, 3, new relacion("y-x", new regla(1)));

            nivelColectivo.agregarRelacion(7, 3, new relacion("y-x", new regla(1)));

            nivelColectivo.agregarRelacion(8, 6, new relacion("x/15", new regla(1)));
            nivelColectivo.agregarRelacion(8, 7, new relacion("x/25", new regla(350, ">")));
            nivelColectivo.agregarRelacion(8, 8, new relacion("0", new regla(500, ">=")));

            Nivel nivelMicrobus = new Nivel("Microbus");

            Elemento demandaMicrobus = new Elemento("Demanda de clientes microbus", 0);

            nivelMicrobus.agregarElemento(precioPasajeMicro);
            nivelMicrobus.agregarElemento(precioPetroleo);
            nivelMicrobus.agregarElemento(demandaMicrobus);
            nivelMicrobus.agregarElemento(gananciaMicro);
            nivelMicrobus.agregarElemento(new Elemento("Distancia recorrida", 40));
            nivelMicrobus.agregarElemento(new Elemento("Petroleo ocupado", 200));
            nivelMicrobus.agregarElemento(new Elemento("Perdida por desgaste", 0));
            nivelMicrobus.agregarElemento(new Elemento("Perdida por reparacion", 0));
            nivelMicrobus.agregarElemento(new Elemento("Desgaste (Kilometraje acumulado)", 0));

            //Relaciones:
            //nivelMicrobus.agregarRelacion(1, 3, new relacion("x", new regla(1)));
            nivelMicrobus.agregarRelacion(0, 3, new relacion("x", new regla(1)));
            nivelMicrobus.agregarRelacion(0, 2, new relacion("logx*(x/6)", new regla(1)));

            nivelMicrobus.agregarRelacion(1, 0, new relacion("logx*(x/5)", new regla(1)));
            nivelMicrobus.agregarRelacion(1, 5, new relacion("x", new regla(1)));

            nivelMicrobus.agregarRelacion(2, 3, new relacion("y*x", new regla(1)));

            nivelMicrobus.agregarRelacion(4, 5, new relacion("y*(x/6)", new regla(1)));
            nivelMicrobus.agregarRelacion(4, 8, new relacion("y+x", new regla(1)));

            nivelMicrobus.agregarRelacion(5, 3, new relacion("y-x", new regla(1)));

            nivelMicrobus.agregarRelacion(6, 3, new relacion("y-x", new regla(1)));

            nivelMicrobus.agregarRelacion(7, 3, new relacion("y-x", new regla(1)));

            nivelMicrobus.agregarRelacion(8, 6, new relacion("x/10", new regla(1)));
            nivelMicrobus.agregarRelacion(8, 7, new relacion("x/15", new regla(350, ">")));
            nivelMicrobus.agregarRelacion(8, 8, new relacion("0", new regla(500, ">=")));

            Nivel nivelUsuario = new Nivel("Demanda usuarios");
            nivelUsuario.agregarElemento(cantidadTotalUsuarios);
            nivelUsuario.agregarElemento(demandaColectivo);
            nivelUsuario.agregarElemento(demandaMicrobus);

            nivelUsuario.agregarRelacion(1, 0, new relacion("x", new regla(1)));
            nivelUsuario.agregarRelacion(2, 0, new relacion("y+x", new regla(1)));

            Nivel petroleo = new Nivel("Indicadores economicos");

            Elemento inflacion = new Elemento("Inflación económica", 1);
            Elemento deuda = new Elemento("Deuda familiar acumulada del mes", 7000);
            Elemento gastoDiario = new Elemento("Gasto familiar diario", 6000);

            petroleo.agregarElemento(precioPetroleo);
            petroleo.agregarElemento(precioBencina);
            petroleo.agregarElemento(inflacion);
            petroleo.agregarElemento(gastoDiario);

            petroleo.agregarRelacion(0, 1, new relacion("x*(15/10)", new regla(1)));
            petroleo.agregarRelacion(0, 2, new relacion("y-2", new regla(3)));

            petroleo.agregarRelacion(1, 2, new relacion("y+4", new regla(5)));

            petroleo.agregarRelacion(2, 0, new relacion("((x/100)+1)*y", new regla(30)));
            petroleo.agregarRelacion(2, 2, new relacion("y*(-1)", new regla(0, "<", 5)));
            petroleo.agregarRelacion(2, 3, new relacion("((x/100)+1)*y", new regla(30)));

            Elemento ahorro = new Elemento("Ahorro familiar", 0);
            Nivel familiaColectivero = new Nivel("Familia colectivero");

            familiaColectivero.agregarElemento(gananciaDiariaColectivero);
            familiaColectivero.agregarElemento(gastoDiario);
            familiaColectivero.agregarElemento(ahorro);
            familiaColectivero.agregarElemento(deuda);

            familiaColectivero.agregarRelacion(0, 2, new relacion("y+x", new regla(1)));

            familiaColectivero.agregarRelacion(1, 3, new relacion("y+x", new regla(1)));

            //Si el ahorro es mayor a 120000 pesos, la familia comienza a gastar más dinero
            familiaColectivero.agregarRelacion(2, 3, new relacion("(x/20)+y", new regla(120000, ">")));

            familiaColectivero.agregarRelacion(3, 2, new relacion("y-x", new regla(30)));
            familiaColectivero.agregarRelacion(3, 3, new relacion("0", new regla(30)));

            sistema.agregarNivel(primerNivel);
            sistema.agregarNivel(nivelColectivo);
            sistema.agregarNivel(nivelMicrobus);
            sistema.agregarNivel(nivelUsuario);
            sistema.agregarNivel(petroleo);
            sistema.agregarNivel(familiaColectivero);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: SW2grupoA/MBCIF
    public static void Main(string[] args)
    {
        /*uno=new Elemento("uno", 1);
        dos=new Elemento("dos", 2);
        Elemento tres = new Elemento("tres", 3);
        Elemento cuatro = new Elemento("cuatro", 4);

        miNivel=new Nivel("Nivel Uno");

        miNivel.agregarElemento(uno);
        miNivel.agregarElemento(dos);

        miNivel.agregarRelacion(0,1,new relacion("4*x",new regla(1)));
        miNivel.agregarRelacion(1,0, new relacion("y-x", new regla(1)));

        miNivel.agregarElemento(tres);

        miNivel.agregarRelacion(2, 0, new relacion("x/2", new regla(2)));

        Nivel nivelDos = new Nivel("Nivel dos");

        nivelDos.agregarElemento(tres);
        nivelDos.agregarElemento(cuatro);
        nivelDos.agregarRelacion(1, 0, new relacion("x^2-2", new regla(2)));
        nivelDos.agregarRelacion(0, 1, new relacion("x+1", new regla(4)));
        nivelDos.agregarRelacion(0, 0, new relacion("3", new regla(50000, ">")));

        Sistema elSistema = new Sistema();

        elSistema.agregarNivel(miNivel);
        elSistema.agregarNivel(nivelDos);

        //*/

        //Console.WriteLine(new calculos().leerFuncion("(x^2/6000)+300", 1));
        //Console.ReadKey();

        Sistema unSistema = new Sistema();

        Nivel primerNivel = new Nivel("Primer nivel");
        primerNivel.agregarElemento(new Elemento("Colectivo", 0));
        primerNivel.agregarElemento(new Elemento("Microbus", 0));
        primerNivel.agregarElemento(new Elemento("Usuario", 0));
        primerNivel.agregarElemento(new Elemento("Combustible", 0));

        Nivel nivelColectivo = new Nivel("Colectivo");

        Elemento demandaColectivo = new Elemento("Demanda de clientes colectivo", 0);

        nivelColectivo.agregarElemento(primerNivel.listaElementos[0]);
        nivelColectivo.agregarElemento(new Elemento("Precio pasaje colectivo", 200));
        nivelColectivo.agregarElemento(new Elemento("Precio Bencina", 150));
        nivelColectivo.agregarElemento(demandaColectivo);
        nivelColectivo.agregarElemento(new Elemento("Ganancia", 2000));
        nivelColectivo.agregarElemento(new Elemento("Distancia recorrida", 1000));
        nivelColectivo.agregarElemento(new Elemento("Bencina ocupada", 10));

        //Relaciones
        //nivelColectivo.agregarRelacion(1, 3, new relacion("x*(6/13)", new regla(1)));
        nivelColectivo.agregarRelacion(1, 4, new relacion("x", new regla(1)));

        nivelColectivo.agregarRelacion(2, 1, new relacion("x*(6/7)", new regla(1)));
        nivelColectivo.agregarRelacion(2, 2, new relacion("y+5", new regla(10)));
        nivelColectivo.agregarRelacion(2, 3, new relacion("x*(1/10)", new regla(1)));
        nivelColectivo.agregarRelacion(2, 6, new relacion("x", new regla(1)));

        nivelColectivo.agregarRelacion(3, 4, new relacion("y*x", new regla(1)));
        nivelColectivo.agregarRelacion(3, 5, new relacion("x*10", new regla(1)));

        nivelColectivo.agregarRelacion(5, 6, new relacion("y*(x/12)", new regla(1)));
        nivelColectivo.agregarRelacion(6, 4, new relacion("y-x", new regla(1)));

        Nivel nivelMicrobus = new Nivel("Microbus");

        Elemento demandaMicrobus = new Elemento("Demanda de clientes microbus", 0);

        nivelMicrobus.agregarElemento(primerNivel.listaElementos[1]);
        nivelMicrobus.agregarElemento(new Elemento("Precio pasaje", 150));
        nivelMicrobus.agregarElemento(new Elemento("Precio petróleo", 140));
        nivelMicrobus.agregarElemento(demandaMicrobus);
        nivelMicrobus.agregarElemento(new Elemento("Ganancia", 0));
        nivelMicrobus.agregarElemento(new Elemento("Distancia recorrida", 1000));
        nivelMicrobus.agregarElemento(new Elemento("Petroleo ocupado", 200));

        //Relaciones:
        //nivelMicrobus.agregarRelacion(1, 3, new relacion("x", new regla(1)));
        nivelMicrobus.agregarRelacion(1, 4, new relacion("x", new regla(1)));

        nivelMicrobus.agregarRelacion(2, 1, new relacion("x*(4/7)", new regla(1)));
        nivelMicrobus.agregarRelacion(2, 2, new relacion("y+(48/10)", new regla(10)));
        nivelMicrobus.agregarRelacion(2, 3, new relacion("x*(1/10)", new regla(1)));
        nivelMicrobus.agregarRelacion(2, 6, new relacion("x", new regla(1)));

        nivelMicrobus.agregarRelacion(3, 4, new relacion("y*x", new regla(1)));
        nivelMicrobus.agregarRelacion(3, 5, new relacion("100", new regla(1)));

        nivelMicrobus.agregarRelacion(5, 6, new relacion("y*(x/12)", new regla(1)));
        nivelMicrobus.agregarRelacion(6, 4, new relacion("y-x", new regla(1)));

        Nivel nivelUsuario = new Nivel("Demanda usuarios");
        nivelUsuario.agregarElemento(primerNivel.listaElementos[2]);
        nivelUsuario.agregarElemento(demandaColectivo);
        nivelUsuario.agregarElemento(demandaMicrobus);

        //nivelUsuario.agregarRelacion(1, 2, new relacion("y-x/100", new regla(1)));

        unSistema.agregarNivel(primerNivel);
        unSistema.agregarNivel(nivelColectivo);
        unSistema.agregarNivel(nivelMicrobus);
        unSistema.agregarNivel(nivelUsuario);

        while (true)
        {
            Console.Clear();
            unSistema.iterar();
            unSistema.imprimirSistema();
            Console.WriteLine(unSistema.obtenerEstado() + "\n");
            System.Threading.Thread.Sleep(1000);
        }

        /*
        for(int j=0; j<elSistema.valores.Count;j++){
            for(int k=0; k< elSistema.valores[j].Count;k++){
                Console.Write(elSistema.valores[j][k]+ " ");
            }
            Console.WriteLine();
        }*/
    }