Package operators

Examples of operators.MULTIMAX


                    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  
                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.getTag(tags[i]).getItemList(Item.USER)){
                    ArrayList<FaspFuzzyExpression> list_max_U1 = new ArrayList<FaspFuzzyExpression>();
                    for(String user_j : ff.getTag(tags[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(
                            "MAXT_"+tags[i]+"_"+tags[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.getTag(tags[j]).getItemList(Item.USER)){
                    ArrayList<FaspFuzzyExpression> list_max_U2 = new ArrayList<FaspFuzzyExpression>();
                    for(String user_i : ff.getTag(tags[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(
                            "MAXT_"+tags[j]+"_"+tags[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(
                        "OP1T_"+tags[i]+"_"+tags[j]+"_U1"),false,false,null);
                GroundLiteral litt_op1_U2 = new GroundLiteral(new GroundPredicate(
                        "OP1T_"+tags[i]+"_"+tags[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 op1T1 en op1T2
                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(
                        "OP2T_"+tags[i]+"_"+tags[j]+"_U"),false,false,null);
                rules.add(new GroundRegularRule(litt_op2_U, list_op2_U, 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.getTag(tags[i]).getItemList(Item.RESOURCE)){
                    ArrayList<FaspFuzzyExpression> list_max_R1 = new ArrayList<FaspFuzzyExpression>();
                    for(String res_j : ff.getTag(tags[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(
                            "MAXT_"+tags[i]+"_"+tags[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.getTag(tags[j]).getItemList(Item.RESOURCE)){
                    ArrayList<FaspFuzzyExpression> list_max_R2 = new ArrayList<FaspFuzzyExpression>();
                    for(String res_i : ff.getTag(tags[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(
                            "MAXT_"+tags[j]+"_"+tags[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(
View Full Code Here


            ArrayList<FaspFuzzyExpression> max_r1r2t1_list = new ArrayList<FaspFuzzyExpression>();
            for(String tag2 : map_res_on_tag.get(r2)){
                max_r1r2t1_list.add(new GroundLiteral(new GroundPredicate("SIMT("+tag1+","+tag2+")"),false, false,null));
            }
            GroundLiteral maxTR = new GroundLiteral(new GroundPredicate("MAXTR(tag2|"+tag1+")"),false, false,null);
            rules.add(new GroundRegularRule(maxTR, max_r1r2t1_list,new MULTIMAX()));
            op1_r1r2t1_list.add(maxTR);
        }
        rules.add(new GroundRegularRule(op1_r1r2t1, op1_r1r2t1_list, op1));
        ArrayList<FaspFuzzyExpression> op1_r1r2t2_list = new ArrayList<FaspFuzzyExpression>();
        for(String tag2 : map_res_on_tag.get(r2)){
            ArrayList<FaspFuzzyExpression> max_r1r2t2_list = new ArrayList<FaspFuzzyExpression>();
            for(String tag1 : map_res_on_tag.get(r1)){
                max_r1r2t2_list.add(new GroundLiteral(new GroundPredicate("SIMT("+tag2+","+tag1+")"),false, false,null));
            }
            GroundLiteral maxTR = new GroundLiteral(new GroundPredicate("MAXTR(tag1|"+tag2+")"),false, false,null);
            rules.add(new GroundRegularRule(maxTR, max_r1r2t2_list, new MULTIMAX()));
            op1_r1r2t2_list.add(maxTR);
        }
        rules.add(new GroundRegularRule(op1_r1r2t2, op1_r1r2t2_list, op1));
        ArrayList<FaspFuzzyExpression> op2_r1r2t_list = new ArrayList<FaspFuzzyExpression>();
        op2_r1r2t_list.add(op1_r1r2t1); op2_r1r2t_list.add(op1_r1r2t2);
        rules.add(new GroundRegularRule(op2_r1r2t, op2_r1r2t_list, op2));
        /**RU**/
        ArrayList<FaspFuzzyExpression> op1_r1r2u1_list = new ArrayList<FaspFuzzyExpression>();
        for(String user1 : map_res_on_user.get(r1)){
            ArrayList<FaspFuzzyExpression> max_r1r2u1_list = new ArrayList<FaspFuzzyExpression>();
            for(String user2 : map_res_on_user.get(r2)){
                max_r1r2u1_list.add(new GroundLiteral(new GroundPredicate("SIMU("+user1+","+user2+")"),false, false,null));
            }
            GroundLiteral maxUR = new GroundLiteral(new GroundPredicate("MAXUR(user2|"+user1+")"),false, false,null);
            rules.add(new GroundRegularRule(maxUR, max_r1r2u1_list,new MULTIMAX()));
            op1_r1r2u1_list.add(maxUR);
        }
        rules.add(new GroundRegularRule(op1_r1r2u1, op1_r1r2u1_list, op1));
        ArrayList<FaspFuzzyExpression> op1_r1r2u2_list = new ArrayList<FaspFuzzyExpression>();
        for(String user2 : map_res_on_user.get(r2)){
            ArrayList<FaspFuzzyExpression> max_r1r2u2_list = new ArrayList<FaspFuzzyExpression>();
            for(String user1 : map_res_on_user.get(r1)){
                max_r1r2u2_list.add(new GroundLiteral(new GroundPredicate("SIMU("+user2+","+user1+")"),false, false,null));
            }
            GroundLiteral maxUR = new GroundLiteral(new GroundPredicate("MAXTR(user1|"+user2+")"),false, false,null);
            rules.add(new GroundRegularRule(maxUR, max_r1r2u2_list, new MULTIMAX()));
            op1_r1r2u2_list.add(maxUR);
        }
        rules.add(new GroundRegularRule(op1_r1r2u2, op1_r1r2u2_list, op1));
        ArrayList<FaspFuzzyExpression> op2_r1r2u_list = new ArrayList<FaspFuzzyExpression>();
        op2_r1r2u_list.add(op1_r1r2u1); op2_r1r2u_list.add(op1_r1r2u2);
        rules.add(new GroundRegularRule(op2_r1r2u, op2_r1r2u_list, op2));
        /**Rop3**/
        ArrayList<FaspFuzzyExpression> op3_r1r2_list = new ArrayList<FaspFuzzyExpression>();
        op3_r1r2_list.add(op2_r1r2u); op3_r1r2_list.add(op2_r1r2u);
        rules.add(new GroundRegularRule(r1r2, op3_r1r2_list, op3));
        rules.add(new GroundRegularRule(r2r1, op3_r1r2_list, op3));

        /*U*/
        String[] users = map_user_on_tag.keySet().toArray(new String[0]);
        for(int i=0; i< users.length; i++){
            for(int j=i+1; j< users.length; j++){
                /**UT**/
                ArrayList<FaspFuzzyExpression> op1_u1u2t1_list = new ArrayList<FaspFuzzyExpression>();
                for(String tag1 : map_user_on_tag.get(users[i])){
                    ArrayList<FaspFuzzyExpression> max_u1u2t1_list = new ArrayList<FaspFuzzyExpression>();
                    for(String tag2 : map_user_on_tag.get(users[j])){
                        max_u1u2t1_list.add(new GroundLiteral(new GroundPredicate("SIMT("+tag1+","+tag2+")"),false, false,null));
                    }
                    GroundLiteral maxTU = new GroundLiteral(new GroundPredicate("MAXTU(tag2|"+tag1+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxTU, max_u1u2t1_list,new MULTIMAX()));
                    op1_u1u2t1_list.add(maxTU);
                }
                GroundLiteral op1_u1u2t1 = new GroundLiteral(new GroundPredicate("OP1U_tag1("+users[i]+","+users[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_u1u2t1, op1_u1u2t1_list, op1));
                ArrayList<FaspFuzzyExpression> op1_u1u2t2_list = new ArrayList<FaspFuzzyExpression>();
                for(String tag2 : map_user_on_tag.get(users[j])){
                    ArrayList<FaspFuzzyExpression> max_u1u2t2_list = new ArrayList<FaspFuzzyExpression>();
                    for(String tag1 : map_user_on_tag.get(users[i])){
                        max_u1u2t2_list.add(new GroundLiteral(new GroundPredicate("SIMT("+tag2+","+tag1+")"),false, false,null));
                    }
                    GroundLiteral maxTU = new GroundLiteral(new GroundPredicate("MAXTR(tag1|"+tag2+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxTU, max_u1u2t2_list, new MULTIMAX()));
                    op1_u1u2t2_list.add(maxTU);
                }
                GroundLiteral op1_u1u2t2 = new GroundLiteral(new GroundPredicate("OP1U_tag2("+users[i]+","+users[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_u1u2t2, op1_u1u2t2_list, op1));
                ArrayList<FaspFuzzyExpression> op2_u1u2t_list = new ArrayList<FaspFuzzyExpression>();
                op2_u1u2t_list.add(op1_u1u2t1); op2_u1u2t_list.add(op1_u1u2t2);
                GroundLiteral op2_u1u2t = new GroundLiteral(new GroundPredicate("OP2U_tag("+users[i]+","+users[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op2_u1u2t, op2_u1u2t_list, op2));
                /**UR**/
                ArrayList<FaspFuzzyExpression> op1_u1u2r1_list = new ArrayList<FaspFuzzyExpression>();
                for(String res1 : map_user_on_res.get(users[i])){
                    ArrayList<FaspFuzzyExpression> max_u1u2r1_list = new ArrayList<FaspFuzzyExpression>();
                    for(String res2 : map_user_on_res.get(users[j])){
                        max_u1u2r1_list.add(new GroundLiteral(new GroundPredicate("SIMR("+res1+","+res2+")"),false, false,null));
                    }
                    GroundLiteral maxRU = new GroundLiteral(new GroundPredicate("MAXRU(res2|"+res1+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxRU, max_u1u2r1_list,new MULTIMAX()));
                    op1_u1u2r1_list.add(maxRU);
                }
                GroundLiteral op1_u1u2r1 = new GroundLiteral(new GroundPredicate("OP1U_res1("+users[i]+","+users[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_u1u2r1, op1_u1u2r1_list, op1));
                ArrayList<FaspFuzzyExpression> op1_u1u2r2_list = new ArrayList<FaspFuzzyExpression>();
                for(String res2 : map_user_on_res.get(users[j])){
                    ArrayList<FaspFuzzyExpression> max_u1u2r2_list = new ArrayList<FaspFuzzyExpression>();
                    for(String res1 : map_user_on_res.get(users[i])){
                        max_u1u2r2_list.add(new GroundLiteral(new GroundPredicate("SIMR("+res2+","+res1+")"),false, false,null));
                    }
                    GroundLiteral maxRU = new GroundLiteral(new GroundPredicate("MAXRU(res1|"+res2+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxRU, max_u1u2r2_list,new MULTIMAX()));
                    op1_u1u2r2_list.add(maxRU);
                }
                GroundLiteral op1_u1u2r2 = new GroundLiteral(new GroundPredicate("OP1U_res2("+users[i]+","+users[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_u1u2r1, op1_u1u2r1_list, op1));
                GroundLiteral op2_u1u2r = new GroundLiteral(new GroundPredicate("OP2U_res("+users[i]+","+users[j]+")"),false, false,null);
                ArrayList<FaspFuzzyExpression> op2_u1u2r_list = new ArrayList<FaspFuzzyExpression>();
                op2_u1u2r_list.add(op1_r1r2u1); op2_u1u2r_list.add(op1_u1u2r2);
                rules.add(new GroundRegularRule(op2_u1u2r, op2_u1u2r_list, op2));
                /**Uop3**/
                GroundLiteral op3_u1u2 = new GroundLiteral(new GroundPredicate("SIMU("+users[i]+","+users[j]+")"),false, false,null);
                GroundLiteral op3_u2u1 = new GroundLiteral(new GroundPredicate("SIMU("+users[j]+","+users[i]+")"),false, false,null);
                ArrayList<FaspFuzzyExpression> op3_u1u2_list = new ArrayList<FaspFuzzyExpression>();
                op3_u1u2_list.add(op2_u1u2t); op3_u1u2_list.add(op2_u1u2r);
                rules.add(new GroundRegularRule(op3_u1u2, op3_u1u2_list, op3));
                rules.add(new GroundRegularRule(op3_u2u1, op3_u1u2_list, op3));
            }
        }

        /*T*/
        String[] tags = map_tag_on_user.keySet().toArray(new String[0]);
        for(int i=0; i<tags.length; i++){
            for(int j=i+1; j< tags.length; j++){
                /**TU**/
                ArrayList<FaspFuzzyExpression> op1_t1t2u1_list = new ArrayList<FaspFuzzyExpression>();
                for(String user1 : map_tag_on_user.get(tags[i])){
                    ArrayList<FaspFuzzyExpression> max_t1t2u1_list = new ArrayList<FaspFuzzyExpression>();
                    for(String user2 : map_tag_on_user.get(tags[j])){
                        max_t1t2u1_list.add(new GroundLiteral(new GroundPredicate("SIMU("+user1+","+user2+")"),false, false,null));
                    }
                    GroundLiteral maxUT = new GroundLiteral(new GroundPredicate("MAXUT(user2|"+user1+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxUT, max_t1t2u1_list,new MULTIMAX()));
                    op1_t1t2u1_list.add(maxUT);
                }
                GroundLiteral op1_t1t2u1 = new GroundLiteral(new GroundPredicate("OP1T_user1("+tags[i]+","+tags[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_t1t2u1, op1_t1t2u1_list, op1));
                ArrayList<FaspFuzzyExpression> op1_t1t2u2_list = new ArrayList<FaspFuzzyExpression>();
                for(String user2 : map_tag_on_user.get(tags[j])){
                    ArrayList<FaspFuzzyExpression> max_t1t2u2_list = new ArrayList<FaspFuzzyExpression>();
                    for(String user1 : map_tag_on_user.get(tags[i])){
                        max_t1t2u2_list.add(new GroundLiteral(new GroundPredicate("SIMU("+user2+","+user1+")"),false, false,null));
                    }
                    GroundLiteral maxUT = new GroundLiteral(new GroundPredicate("MAXUT(user1|"+user2+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxUT, max_t1t2u2_list,new MULTIMAX()));
                    op1_t1t2u2_list.add(maxUT);
                }
                GroundLiteral op1_t1t2u2 = new GroundLiteral(new GroundPredicate("OP1T_user2("+tags[i]+","+tags[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_t1t2u2, op1_t1t2u2_list, op1));
                ArrayList<FaspFuzzyExpression> op2_t1t2u_list = new ArrayList<FaspFuzzyExpression>();
                op2_t1t2u_list.add(op1_t1t2u1); op2_t1t2u_list.add(op1_t1t2u2);
                GroundLiteral op2_t1t2u = new GroundLiteral(new GroundPredicate("OP2T_user("+tags[i]+","+tags[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op2_t1t2u, op2_t1t2u_list, op2));
                /**TR**/
                ArrayList<FaspFuzzyExpression> op1_t1t2r1_list = new ArrayList<FaspFuzzyExpression>();
                for(String res1 : map_tag_on_res.get(tags[i])){
                    ArrayList<FaspFuzzyExpression> max_t1t2r1_list = new ArrayList<FaspFuzzyExpression>();
                    for(String res2 : map_tag_on_res.get(tags[j])){
                        max_t1t2r1_list.add(new GroundLiteral(new GroundPredicate("SIMR("+res1+","+res2+")"),false, false,null));
                    }
                    GroundLiteral maxUR = new GroundLiteral(new GroundPredicate("MAXUR(res2|"+res1+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxUR, max_t1t2r1_list,new MULTIMAX()));
                    op1_t1t2r1_list.add(maxUR);
                }
                GroundLiteral op1_t1t2r1 = new GroundLiteral(new GroundPredicate("OP1T_res1("+tags[i]+","+tags[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_t1t2r1, op1_t1t2r1_list, op1));
                ArrayList<FaspFuzzyExpression> op1_t1t2r2_list = new ArrayList<FaspFuzzyExpression>();
                for(String res2 : map_tag_on_res.get(tags[j])){
                    ArrayList<FaspFuzzyExpression> max_t1t2r2_list = new ArrayList<FaspFuzzyExpression>();
                    for(String res1 : map_tag_on_res.get(tags[i])){
                        max_t1t2r2_list.add(new GroundLiteral(new GroundPredicate("SIMR("+res2+","+res1+")"),false, false,null));
                    }
                    GroundLiteral maxUR = new GroundLiteral(new GroundPredicate("MAXUR(res1|"+res2+")"),false, false,null);
                    rules.add(new GroundRegularRule(maxUR, max_t1t2r2_list,new MULTIMAX()));
                    op1_t1t2r2_list.add(maxUR);
                }
                GroundLiteral op1_t1t2r2 = new GroundLiteral(new GroundPredicate("OP1T_res2("+tags[i]+","+tags[j]+")"),false, false,null);
                rules.add(new GroundRegularRule(op1_t1t2r2, op1_t1t2r2_list, op1));
                ArrayList<FaspFuzzyExpression> op2_t1t2r_list = new ArrayList<FaspFuzzyExpression>();
View Full Code Here

TOP

Related Classes of operators.MULTIMAX

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.