public static void exhaustiveAntiGoalRefineAnalysis(RequirementGraph req_model, ActorAssociationGraph actor_model, int visual_type, int scope) throws IOException, ScriptException {
		// first empty the potential security goal set.
		req_model.ag_elems.clear();
		req_model.ag_links.clear();
		
		String expression_file = req_model.generateFormalExpressionToFile(scope);
		String security_model_file = InfoEnum.current_directory+"/dlv/models/security_model_"+req_model.getLayer().toLowerCase()+".dl ";
		String threat_knowledge = InfoEnum.current_directory+"/dlv/anti_goal_rules/threat_knowledge.rule ";
		
		String refine_rule = "";
		refine_rule = InfoEnum.current_directory+"/dlv/dlv -silent -nofacts "
				+ InfoEnum.current_directory+"/dlv/anti_goal_rules/refine_all.rule "
				+ InfoEnum.current_directory+"/dlv/models/asset_model.dl "
				+ expression_file + security_model_file + threat_knowledge;
		Runtime rt = Runtime.getRuntime();
		Process pr = rt.exec(refine_rule);

		BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
		String line = null;
		
		// parse inference results
		while ((line = input.readLine()) != null) {
			line = line.substring(1, line.length() - 1);
			String[] result = line.split(", ");
			//Assign all security goals with ordered numbers, which are just used as identifiers.
			int number = 1;
			for (String s : result) {
				// only consider related security goals
				if (s.startsWith("ex_refined_anti_goal") && !s.contains("unknown")) {
					// parse facts
					s = s.replaceAll("ex_refined_anti_goal\\(", "");
					s = s.replaceAll("\\)", "");
					String[] ag = s.split(",");

					// create two anti goals, and the refinement relation between them.
					AntiGoal child_ag = req_model.findExhausiveAntiGoalByAttributes(ag[0], ag[1], ag[2], ag[3]);
					AntiGoal parent_ag = req_model.findExhausiveAntiGoalByAttributes(ag[4], ag[5], ag[6], ag[7]);
					
					//add elements to the anti goal graph
					if (child_ag == null) {
						child_ag = new AntiGoal(ag[0], ag[1], ag[2], ag[3],
								InfoEnum.RequirementElementType.ANTI_GOAL.name(), req_model.getLayer());
						child_ag.setId(String.valueOf(number));
						number++;
						req_model.ag_elems.add(child_ag);
					}
					if (parent_ag == null) {
						parent_ag = new AntiGoal(ag[4], ag[5], ag[6], ag[7],
								InfoEnum.RequirementElementType.ANTI_GOAL.name(), req_model.getLayer());
						parent_ag.setId(String.valueOf(number));
						number++;
						req_model.ag_elems.add(parent_ag);
					}
					
					// create the new refinement link (by default is "and")
					RequirementLink new_and_refine = new RequirementLink(
							InfoEnum.RequirementLinkType.AND_REFINE.name(), child_ag, parent_ag);
					new_and_refine.refine_type = ag[8];
					// change the type of the link, if necessary
					if(new_and_refine.refine_type.contains("o_")){
						new_and_refine.setType(InfoEnum.RequirementLinkType.REFINE.name());
					}
					
					//the refinement links should always be added, as there may be several elements that refine/be refined to one element.
					if(!req_model.ag_links.contains(new_and_refine)){
						req_model.ag_links.add(new_and_refine);
					}
					
					//add the refinement link to the target anti goal
					if(new_and_refine.getType().equals(InfoEnum.RequirementLinkType.AND_REFINE.name())){
						parent_ag.and_refine_links.add(new_and_refine);
					} else{
						parent_ag.refine_links.add(new_and_refine);
					}
					child_ag.parent = parent_ag;
					child_ag.parent_link = new_and_refine;	
				}
			}
		}

			//visualize exhaustive refinements via Graphviz
//			if(visual_type==InfoEnum.GRAPHVIZ){
//				// graphviz can generate the three view separately
//				visualizeGraph(req_model, actor_model, InfoEnum.GRAPHVIZ, InfoEnum.INITIAL_VIEW);
//				visualizeGraph(req_model, actor_model, InfoEnum.GRAPHVIZ, InfoEnum.HIGHLIGHT_VIEW);
//				visualizeGraph(req_model, actor_model, InfoEnum.GRAPHVIZ, InfoEnum.SIMPLIFIED_VIEW);
//			}else if (visual_type == InfoEnum.CANVAS){
//				// we only provide one view in the canvas
				visualizeEAGGraph(req_model, actor_model, InfoEnum.CANVAS, InfoEnum.INITIAL_VIEW);
//				// the highlight and simpliefied view are put together in one view
//				visualizeGraph(req_model, actor_model, InfoEnum.CANVAS, InfoEnum.HIGHLIGHT_VIEW);
//			}
//			else{
//				CommandPanel.logger.warning("Visualization type error!");
//			}
		}