Package operators

Examples of operators.ID


        String[] resources = ff.getResourceIds().toArray(new String[0]);
        for(int i=0; i<resources.length; i++){
            ArrayList<FaspFuzzyExpression> listii = new ArrayList<FaspFuzzyExpression>();
            listii.add(new LattVal(1.0));
            rules.add(new GroundRegularRule(new GroundLiteral(new GroundPredicate(
                    "SIMR("+resources[i]+","+resources[i]+")"),false, false,null),listii,new ID()));
            for(int j=i+1; j<resources.length; j++){
                //JACCARD RULES
                double sim_tag = ff.getJaccard(resources[i], resources[j], Item.RESOURCE, Item.TAG);
                double sim_user = ff.getJaccard(resources[i], resources[j], Item.RESOURCE, Item.USER);

                ArrayList<FaspFuzzyExpression> list = new ArrayList<FaspFuzzyExpression>(1);
                ArrayList<FaspFuzzyExpression> list_reverse = new ArrayList<FaspFuzzyExpression>(1);
                list.add(new LattVal((((double)1/2)*sim_tag)*(((double)1/2)*sim_user)));

                GroundLiteral SIMR_litt =
                new GroundLiteral(new GroundPredicate("SIMR("+resources[i]+","+resources[j]+")"),false, false,null);

                GroundRegularRule rule = new GroundRegularRule(SIMR_litt, list, new ID());

                list_reverse.add(SIMR_litt);

                GroundRegularRule rule_reverse = new GroundRegularRule(
                        new GroundLiteral(new GroundPredicate("SIMR("+resources[j]+","+resources[i]+")"),
                        false, false,null), list_reverse, new ID());

                rules.add(rule);
                rules.add(rule_reverse);

                //Recursieve regels onderdeel T              
                ArrayList<FaspFuzzyExpression> list_op1_T1 = new ArrayList<FaspFuzzyExpression>();
                ArrayList<FaspFuzzyExpression> list_op1_T2 = new ArrayList<FaspFuzzyExpression>();
                //MAX van T1 met alle tags van T2
                for(String tag_i : ff.getResource(resources[i]).getItemList(Item.TAG)){
                    ArrayList<FaspFuzzyExpression> list_max_T1 = new ArrayList<FaspFuzzyExpression>();
                    for(String tag_j : ff.getResource(resources[j]).getItemList(Item.TAG)){
                        list_max_T1.add(new GroundLiteral(new GroundPredicate("SIMT("+tag_i+","+tag_j+")"),false, false,null));
                    }
                    GroundLiteral litt_max_T1 = new GroundLiteral(new GroundPredicate(
                            "MAXR_"+resources[i]+"_"+resources[j]+"_T1_"+tag_i),false, false,null);
                    GroundRegularRule rule_max_T1 = new GroundRegularRule(litt_max_T1, list_max_T1, new MULTIMAX());
                    rules.add(rule_max_T1);
                    list_op1_T1.add(litt_max_T1);
                }
                //MAX van T2 met alle tags van T1
                for(String tag_j : ff.getResource(resources[j]).getItemList(Item.TAG)){
                    ArrayList<FaspFuzzyExpression> list_max_T2 = new ArrayList<FaspFuzzyExpression>();
                    for(String tag_i : ff.getResource(resources[i]).getItemList(Item.TAG)){
                        list_max_T2.add(new GroundLiteral(new GroundPredicate("SIMT("+tag_j+","+tag_i+")"),false, false,null));
                    }
                    GroundLiteral litt_max_T2 = new GroundLiteral(new GroundPredicate(
                            "MAXR_"+resources[j]+"_"+resources[i]+"_T2_"+tag_j),false, false,null);
                    GroundRegularRule rule_max_T2 = new GroundRegularRule(litt_max_T2, list_max_T2, new MULTIMAX());
                    rules.add(rule_max_T2);
                    list_op1_T2.add(litt_max_T2);
                }
                //op1 van maxT1 en maxT2
                GroundLiteral litt_op1_T1 = new GroundLiteral(new GroundPredicate(
                        "OP1R_"+resources[i]+"_"+resources[j]+"_T1"),false,false,null);
                GroundLiteral litt_op1_T2 = new GroundLiteral(new GroundPredicate(
                        "OP1R_"+resources[i]+"_"+resources[j]+"_T2"),false,false,null);
                rules.add(new GroundRegularRule(litt_op1_T1,list_op1_T1, op1));
                rules.add(new GroundRegularRule(litt_op1_T2,list_op1_T2, op1));
                //op2 van op1T1 en op1T2
                ArrayList<FaspFuzzyExpression> list_op2_T = new ArrayList<FaspFuzzyExpression>();
                list_op2_T.add(litt_op1_T1);
                list_op2_T.add(litt_op1_T2);
                GroundLiteral litt_op2_T = new GroundLiteral(new GroundPredicate(
                        "OP2R_"+resources[i]+"_"+resources[j]+"_T"),false,false,null);
                rules.add(new GroundRegularRule(litt_op2_T, list_op2_T, op2));

                //Recursieve regels onderdeel U
                ArrayList<FaspFuzzyExpression> list_op1_U1 = new ArrayList<FaspFuzzyExpression>();
                ArrayList<FaspFuzzyExpression> list_op1_U2 = new ArrayList<FaspFuzzyExpression>();
                //MAX van U1 met alle tags van U2
                for(String user_i : ff.getResource(resources[i]).getItemList(Item.USER)){
                    ArrayList<FaspFuzzyExpression> list_max_U1 = new ArrayList<FaspFuzzyExpression>();
                    for(String user_j : ff.getResource(resources[j]).getItemList(Item.USER)){
                        list_max_U1.add(new GroundLiteral(new GroundPredicate("SIMU("+user_i+","+user_j+")"),false, false,null));
                    }
                    GroundLiteral litt_max_U1 = new GroundLiteral(new GroundPredicate(
                            "MAXR_"+resources[i]+"_"+resources[j]+"_U1_"+user_i),false, false,null);
                    GroundRegularRule rule_max_U1 = new GroundRegularRule(litt_max_U1, list_max_U1, new MULTIMAX());
                    rules.add(rule_max_U1);
                    list_op1_U1.add(litt_max_U1);
                }
                //MAX van U2 met alle tags van U1
                for(String user_j : ff.getResource(resources[j]).getItemList(Item.USER)){
                    ArrayList<FaspFuzzyExpression> list_max_U2 = new ArrayList<FaspFuzzyExpression>();
                    for(String user_i : ff.getResource(resources[i]).getItemList(Item.USER)){
                        list_max_U2.add(new GroundLiteral(new GroundPredicate("SIMU("+user_j+","+user_i+")"),false, false,null));
                    }
                    GroundLiteral litt_max_U2 = new GroundLiteral(new GroundPredicate(
                            "MAXR_"+resources[j]+"_"+resources[i]+"_U2_"+user_j),false, false,null);
                    GroundRegularRule rule_max_U2 = new GroundRegularRule(litt_max_U2, list_max_U2, new MULTIMAX());
                    rules.add(rule_max_U2);
                    list_op1_U2.add(litt_max_U2);
                }
                //op1 van maxU1 en maxU2
                GroundLiteral litt_op1_U1 = new GroundLiteral(new GroundPredicate(
                        "OP1R_"+resources[i]+"_"+resources[j]+"_U1"),false,false,null);
                GroundLiteral litt_op1_U2 = new GroundLiteral(new GroundPredicate(
                        "OP1R_"+resources[i]+"_"+resources[j]+"_U2"),false,false,null);
                rules.add(new GroundRegularRule(litt_op1_U1, list_op1_U1, op1));
                rules.add(new GroundRegularRule(litt_op1_U2, list_op1_U2, op1));
                //op2 van op1U1 en op1U2
                ArrayList<FaspFuzzyExpression> list_op2_U = new ArrayList<FaspFuzzyExpression>();
                list_op2_U.add(litt_op1_U1);
                list_op2_U.add(litt_op1_U2);
                GroundLiteral litt_op2_U = new GroundLiteral(new GroundPredicate(
                        "OP2R_"+resources[i]+"_"+resources[j]+"_U"),false,false,null);
                rules.add(new GroundRegularRule(litt_op2_U, list_op2_U, op2));

                //op3 van op2T en op2U
                ArrayList<FaspFuzzyExpression> list_op3 = new ArrayList<FaspFuzzyExpression>();
                list_op3.add(litt_op2_U);
                list_op3.add(litt_op2_T);
                rules.add(new GroundRegularRule(SIMR_litt,list_op3, op3));
            }
        }

        //RULES USERS
        String[] users = ff.getUserIds().toArray(new String[0]);
        for(int i=0; i<users.length; i++){
            ArrayList<FaspFuzzyExpression> listii = new ArrayList<FaspFuzzyExpression>();
            listii.add(new LattVal(1.0));
            rules.add(new GroundRegularRule(new GroundLiteral(new GroundPredicate(
                    "SIMU("+users[i]+","+users[i]+")"),false, false,null),listii,new ID()));
            for(int j=i+1; j<users.length; j++){
                //JACCARD RULES
                double sim_tag = ff.getJaccard(users[i], users[j], Item.USER, Item.TAG);
                double sim_res = ff.getJaccard(users[i], users[j], Item.USER, Item.RESOURCE);

                ArrayList<FaspFuzzyExpression> list = new ArrayList<FaspFuzzyExpression>(1);
                ArrayList<FaspFuzzyExpression> list_reverse = new ArrayList<FaspFuzzyExpression>(1);
                list.add(new LattVal((((double)1/2)*sim_tag)*(((double)1/2)*sim_res)));

                GroundLiteral SIMU_litt =
                new GroundLiteral(new GroundPredicate("SIMU("+users[i]+","+users[j]+")"),false, false,null);

                GroundRegularRule rule = new GroundRegularRule(SIMU_litt, list, new ID());

                list_reverse.add(SIMU_litt);

                GroundRegularRule rule_reverse = new GroundRegularRule(
                        new GroundLiteral(new GroundPredicate("SIMU("+users[j]+","+users[i]+")"),
                        false, false,null), list_reverse, new ID());

                rules.add(rule);
                rules.add(rule_reverse);

                //Recursieve regels onderdeel T
                ArrayList<FaspFuzzyExpression> list_op1_T1 = new ArrayList<FaspFuzzyExpression>();
                ArrayList<FaspFuzzyExpression> list_op1_T2 = new ArrayList<FaspFuzzyExpression>();
                //MAX van T1 met alle tags van T2
                for(String tag_i : ff.getUser(users[i]).getItemList(Item.TAG)){
                    ArrayList<FaspFuzzyExpression> list_max_T1 = new ArrayList<FaspFuzzyExpression>();
                    for(String tag_j : ff.getUser(users[j]).getItemList(Item.TAG)){
                        list_max_T1.add(new GroundLiteral(new GroundPredicate("SIMT("+tag_i+","+tag_j+")"),false, false,null));
                    }
                    GroundLiteral litt_max_T1 = new GroundLiteral(new GroundPredicate(
                            "MAXU_"+users[i]+"_"+users[j]+"_T1_"+tag_i),false, false,null);
                    GroundRegularRule rule_max_T1 = new GroundRegularRule(litt_max_T1, list_max_T1, new MULTIMAX());
                    rules.add(rule_max_T1);
                    list_op1_T1.add(litt_max_T1);
                }
                //MAX van T2 met alle tags van T1
                for(String tag_j : ff.getUser(users[j]).getItemList(Item.TAG)){
                    ArrayList<FaspFuzzyExpression> list_max_T2 = new ArrayList<FaspFuzzyExpression>();
                    for(String tag_i : ff.getUser(users[i]).getItemList(Item.TAG)){
                        list_max_T2.add(new GroundLiteral(new GroundPredicate("SIMT("+tag_j+","+tag_i+")"),false, false,null));
                    }
                    GroundLiteral litt_max_T2 = new GroundLiteral(new GroundPredicate(
                            "MAXU_"+users[j]+"_"+users[i]+"_T2_"+tag_j),false, false,null);
                    GroundRegularRule rule_max_T2 = new GroundRegularRule(litt_max_T2, list_max_T2, new MULTIMAX());
                    rules.add(rule_max_T2);
                    list_op1_T2.add(litt_max_T2);
                }
                //op1 van maxT1 en maxT2
                GroundLiteral litt_op1_T1 = new GroundLiteral(new GroundPredicate(
                        "OP1U_"+users[i]+"_"+users[j]+"_T1"),false,false,null);
                GroundLiteral litt_op1_T2 = new GroundLiteral(new GroundPredicate(
                        "OP1U_"+users[i]+"_"+users[j]+"_T2"),false,false,null);
                rules.add(new GroundRegularRule(litt_op1_T1,list_op1_T1, op1));
                rules.add(new GroundRegularRule(litt_op1_T2,list_op1_T2, op1));
                //op2 van op1T1 en op1T2
                ArrayList<FaspFuzzyExpression> list_op2_T = new ArrayList<FaspFuzzyExpression>();
                list_op2_T.add(litt_op1_T1);
                list_op2_T.add(litt_op1_T2);
                GroundLiteral litt_op2_T = new GroundLiteral(new GroundPredicate(
                        "OP2U_"+users[i]+"_"+users[j]+"_T"),false,false,null);
                rules.add(new GroundRegularRule(litt_op2_T, list_op2_T, op2));

                //Recursieve regels onderdeel R
                ArrayList<FaspFuzzyExpression> list_op1_R1 = new ArrayList<FaspFuzzyExpression>();
                ArrayList<FaspFuzzyExpression> list_op1_R2 = new ArrayList<FaspFuzzyExpression>();
                //MAX van R1 met alle tags van R2
                for(String res_i : ff.getUser(users[i]).getItemList(Item.RESOURCE)){
                    ArrayList<FaspFuzzyExpression> list_max_R1 = new ArrayList<FaspFuzzyExpression>();
                    for(String res_j : ff.getUser(users[j]).getItemList(Item.RESOURCE)){
                        list_max_R1.add(new GroundLiteral(new GroundPredicate("SIMR("+res_i+","+res_j+")"),false, false,null));
                    }
                    GroundLiteral litt_max_R1 = new GroundLiteral(new GroundPredicate(
                            "MAXU_"+users[i]+"_"+users[j]+"_R1_"+res_i),false, false,null);
                    GroundRegularRule rule_max_R1 = new GroundRegularRule(litt_max_R1, list_max_R1, new MULTIMAX());
                    rules.add(rule_max_R1);
                    list_op1_R1.add(litt_max_R1);
                }
                //MAX van R2 met alle tags van R1
                for(String res_j : ff.getUser(users[j]).getItemList(Item.RESOURCE)){
                    ArrayList<FaspFuzzyExpression> list_max_R2 = new ArrayList<FaspFuzzyExpression>();
                    for(String res_i : ff.getUser(users[i]).getItemList(Item.RESOURCE)){
                        list_max_R2.add(new GroundLiteral(new GroundPredicate("SIMR("+res_j+","+res_i+")"),false, false,null));
                    }
                    GroundLiteral litt_max_R2 = new GroundLiteral(new GroundPredicate(
                            "MAXU_"+users[j]+"_"+users[i]+"_R2_"+res_j),false, false,null);
                    GroundRegularRule rule_max_R2 = new GroundRegularRule(litt_max_R2, list_max_R2, new MULTIMAX());
                    rules.add(rule_max_R2);
                    list_op1_R2.add(litt_max_R2);
                }
                //op1 van maxR1 en maxR2
                GroundLiteral litt_op1_R1 = new GroundLiteral(new GroundPredicate(
                        "OP1U_"+users[i]+"_"+users[j]+"_R1"),false,false,null);
                GroundLiteral litt_op1_R2 = new GroundLiteral(new GroundPredicate(
                        "OP1U_"+users[i]+"_"+users[j]+"_R2"),false,false,null);
                rules.add(new GroundRegularRule(litt_op1_R1, list_op1_R1, op1));
                rules.add(new GroundRegularRule(litt_op1_R2, list_op1_R2, op1));
                //op2 van op1R1 en op1R2
                ArrayList<FaspFuzzyExpression> list_op2_R = new ArrayList<FaspFuzzyExpression>();
                list_op2_R.add(litt_op1_R1);
                list_op2_R.add(litt_op1_R2);
                GroundLiteral litt_op2_R = new GroundLiteral(new GroundPredicate(
                        "OP2U_"+users[i]+"_"+users[j]+"_R"),false,false,null);
                rules.add(new GroundRegularRule(litt_op2_R, list_op2_R, op2));

                //op3 van op2R en op2R
                ArrayList<FaspFuzzyExpression> list_op3 = new ArrayList<FaspFuzzyExpression>();
                list_op3.add(litt_op2_T);
                list_op3.add(litt_op2_R);
                rules.add(new GroundRegularRule(SIMU_litt,list_op3, op3));
            }
        }

        //RULES TAGS
        String[] tags = ff.getTagIds().toArray(new String[0]);
        for(int i=0; i<tags.length; i++){
            ArrayList<FaspFuzzyExpression> listii = new ArrayList<FaspFuzzyExpression>();
            listii.add(new LattVal(1.0));
            rules.add(new GroundRegularRule(new GroundLiteral(new GroundPredicate(
                    "SIMT("+tags[i]+","+tags[i]+")"),false, false,null),listii,new ID()));
            for(int j=i+1; j<tags.length; j++){
                //JACCARD RULES
                double sim_user = ff.getJaccard(tags[i], tags[j], Item.TAG, Item.USER);
                double sim_res = ff.getJaccard(tags[i], tags[j], Item.TAG, Item.RESOURCE);

                ArrayList<FaspFuzzyExpression> list = new ArrayList<FaspFuzzyExpression>(1);
                ArrayList<FaspFuzzyExpression> list_reverse = new ArrayList<FaspFuzzyExpression>(1);
                list.add(new LattVal((((double)1/2)*sim_user)*(((double)1/2)*sim_res)));

                GroundLiteral SIMT_litt =
                new GroundLiteral(new GroundPredicate("SIMT("+tags[i]+","+tags[j]+")"),false, false,null);

                GroundRegularRule rule = new GroundRegularRule(SIMT_litt, list, new ID());

                list_reverse.add(SIMT_litt);

                GroundRegularRule rule_reverse = new GroundRegularRule(
                        new GroundLiteral(new GroundPredicate("SIMT("+tags[j]+","+tags[i]+")"),
                        false, false,null), list_reverse, new ID());

                rules.add(rule);
                rules.add(rule_reverse);

                //Recursieve regels onderdeel U  
View Full Code Here


        ArrayList<FaspFuzzyExpression> ltBtC = new ArrayList<FaspFuzzyExpression>(); ltBtC.add(new LattVal(0.58333));
        ArrayList<FaspFuzzyExpression> ltBtD = new ArrayList<FaspFuzzyExpression>(); ltBtD.add(new LattVal(0.75));
        ArrayList<FaspFuzzyExpression> ltCtD = new ArrayList<FaspFuzzyExpression>(); ltCtD.add(new LattVal(0.83333));

            /*r*/
        rules.add(new GroundRegularRule(r1r1,l1,new ID()));
        rules.add(new GroundRegularRule(r2r2,l1,new ID()));
        rules.add(new GroundRegularRule(r1r2,lr1r2,new ID()));
        rules.add(new GroundRegularRule(r2r1,lr1r2,new ID()));
            /*u*/
        rules.add(new GroundRegularRule(uIuI,l1,new ID()));
        rules.add(new GroundRegularRule(uIIuII,l1,new ID()));
        rules.add(new GroundRegularRule(uIIIuIII,l1,new ID()));
        rules.add(new GroundRegularRule(uIuII,luIuII,new ID()));
        rules.add(new GroundRegularRule(uIIuI,luIuII,new ID()));
        rules.add(new GroundRegularRule(uIuIII,luIuIII,new ID()));
        rules.add(new GroundRegularRule(uIIIuI,luIuIII,new ID()));
        rules.add(new GroundRegularRule(uIIuIII,luIIuIII,new ID()));
        rules.add(new GroundRegularRule(uIIIuII,luIIuIII,new ID()));
            /*t*/
        rules.add(new GroundRegularRule(tAtA,l1,new ID()));
        rules.add(new GroundRegularRule(tBtB,l1,new ID()));
        rules.add(new GroundRegularRule(tCtC,l1,new ID()));
        rules.add(new GroundRegularRule(tDtD,l1,new ID()));
        rules.add(new GroundRegularRule(tAtB,ltAtB,new ID()));
        rules.add(new GroundRegularRule(tBtA,ltAtB,new ID()));
        rules.add(new GroundRegularRule(tAtC,ltAtC,new ID()));
        rules.add(new GroundRegularRule(tCtA,ltAtC,new ID()));
        rules.add(new GroundRegularRule(tAtD,ltAtD,new ID()));
        rules.add(new GroundRegularRule(tDtA,ltAtD,new ID()));
        rules.add(new GroundRegularRule(tBtC,ltBtC,new ID()));
        rules.add(new GroundRegularRule(tCtB,ltBtC,new ID()));
        rules.add(new GroundRegularRule(tBtD,ltBtD,new ID()));
        rules.add(new GroundRegularRule(tDtB,ltBtD,new ID()));
        rules.add(new GroundRegularRule(tCtD,ltCtD,new ID()));
        rules.add(new GroundRegularRule(tDtC,ltCtD,new ID()));


        //RECURSIEVE REGELS

        /*R*/
 
View Full Code Here

TOP

Related Classes of operators.ID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.