package org.opendaylight.controller.routing.MY_TE_TECH.internal; import org.gnu.glpk.GLPK; import org.gnu.glpk.GLPKConstants; import org.gnu.glpk.SWIGTYPE_p_double; import org.gnu.glpk.SWIGTYPE_p_int; import org.gnu.glpk.glp_prob; import org.gnu.glpk.glp_iocp; public class SRLG { double[][] Node_Matrix; double INFINITY=99999999; int Variable_Count=0; int x[][][]; int S[][][]; int shr[][]; int[] first_path; int[] second_path; int first_path_len=0, second_path_len=0; boolean findpath=false; int source=0, destination=0,numpaths=0, numgroups=0; public SRLG(double[][] mat,int[][] shared,int src,int dst, int K, int G) { Node_Matrix=Init_Node_Matrix(mat); Variable_Count=mat.length; source=src-1;//begins from 0 destination=dst-1; numpaths=K; // number of disjoint paths numgroups=G; shr=shared; first_path=new int[mat.length]; second_path=new int[mat.length]; System.out.println("Problem created" +numgroups+" " +shr.length); } public void Solve() { glp_prob lp; glp_iocp iocp; SWIGTYPE_p_int ind; SWIGTYPE_p_double val; int ret; // Create problem lp = GLPK.glp_create_prob(); System.out.println("Problem created"); GLPK.glp_set_prob_name(lp, "SRLG_PROBLEM"); x=new int [Variable_Count][][]; //define variables for(int i=0; i0) { String str1=name.substring(name.lastIndexOf(",")+1,name.indexOf("]")); // System.out.print(str1+" "); if(Integer.valueOf(str1)==1)//first path { System.out.print(name+" "); temp_path1[0][j]=Integer.valueOf(name.substring(name.indexOf("[")+1, name.indexOf(","))); temp_path1[1][j]=Integer.valueOf(name.substring(name.indexOf(",")+1, name.lastIndexOf(","))); j++; } } } System.out.println(); first_path=make_path(temp_path1,j,source,destination); first_path_len=j; System.out.println(); k=0; for(i=1; i <= n; i++) { name = GLPK.glp_get_col_name(lp, i); val = GLPK.glp_mip_col_val(lp, i); if(val>0){ String str1=name.substring(name.lastIndexOf(",")+1,name.indexOf("]")); // System.out.print(str1+" "); if(Integer.valueOf(str1)==2)//second path {k++;} } } int[][] temp_path2=new int[2][k]; j=0; for(i=1; i <= n; i++) { name = GLPK.glp_get_col_name(lp, i); val = GLPK.glp_mip_col_val(lp, i); if(val>0) { String str1=name.substring(name.lastIndexOf(",")+1,name.indexOf("]")); // System.out.print(str1+" "); if(Integer.valueOf(str1)==2)//second path { System.out.print(name+" "); temp_path2[0][j]=Integer.valueOf(name.substring(name.indexOf("[")+1, name.indexOf(","))); temp_path2[1][j]=Integer.valueOf(name.substring(name.indexOf(",")+1, name.lastIndexOf(","))); j++; } } } System.out.println(); second_path=make_path(temp_path2,j,source,destination); second_path_len=j; System.out.println(); } public int[] make_path(int[][] path_matrix, int len,int src, int dst) { int[] path=new int[len+1]; int index=src; int c=0; path[c++]=index; for(int i=0; i