GS k - partition

GSkpart[dataGS_,kk_,Ind_]:=Module[{},
(* Defining of domena and Compile Function FCompile((Subscript[x, 1]),...,(Subscript[x, k])) *)
dom=Table[{0,1},{kk}];
cFunk0[var_]:=Compile[var,Evaluate[Sum[Min[Table[Norm[Table[(Subscript[x, j]),{j,1+(s-1),1+s-1}]-dataGS[[i,1]]]^2,{s, 1,kk}]],{i,Length[dataGS]}]]];
FCompile=cFunk0[Table[{(Subscript[x, i]),_Real},{i,kk}]]; 
						(* Call SymDIRECT *)
Nf=0;
tSym=Timing[
minSym=SymDIRECT[FCompile,dom,DMin->10^(-4),MaxIter->100,Eps->10^(-4)]
];
cenSym=Sort[minSym[[1]]];
If[Ind≠ 0,Print[Style["\nSymDIRECT: ",16,Blue],"centers: ",cenSym,Table[Graphics[{GrayLevel[cenSym[[j]]],Disk[]},ImageSize->20],{j,Length[cenSym]}],"\nF = ",minSym[[2]],"; Nf = ",Nf,"; It = ",iter,"; Time = ",tSym[[1]]]];
		(* Call WKMeans: correction + clusters determining *)
                  (* dataGS: 1.komp-graylevel; 2.komp-pixel; 3.komp-color *)
time=Timing[solGS=WKMeansAdd[w,dataGS,cenSym,1,0]];
Print[Style["WKMeans-1-iter: GS-centers+clusters: ",16,Blue],solGS[[2]],"  ",Table[Graphics[{GrayLevel[solGS[[2,j]]],Disk[]},ImageSize->20],{j,Length[solGS[[2]]]}],"\nF = ",solGS[[3]],"; Iteracija=",solGS[[4]],"; Time = ",time[[1]]];
		(* Centroids calculation by using cluster data of graylevel image !!! *)
centroids0=Table[Mean[WeightedData[solGS[[1,j,All,4]],solGS[[1,j,All,1]]]],{j,Length[solGS[[1]]]}];
dataColor=Table[{podDop[[i,1]],podDop[[i,2]],podDop[[i,1]]},{i,Length[podDop]}]; 
(* dataColor is defined formal, because WKMeansDop calls data with 3 components *)
                                            (* Call WKMeans - Spherical Clusters *)
timeSph=Timing[solColor=WKMeansAdd[w,dataColor,centroids0,5,0]];
Print[Style["Extendet results:",16,Blue],"\nCentroids: ",solColor[[2]],"  ",Table[Graphics[{RGBColor[solColor[[2,j]]],Disk[]},ImageSize->20],{j,Length[solColor[[2]]]}],"\nCLU: ",el=Table[Length[solColor[[1,j]]],{j,kk}],"~",Total[el],"\nF = ",solColor[[3]],"; Iteracija=",solColor[[4]],"; Time = ",timeSph[[1]]];   
If[n==3,Print[FigureVor[dataColor[[All,1]],solColor[[1]],centroids0,solColor[[5]]]]];
			      (* Call MWKMeans - Ellipsoidal Clusters  *)                      
time=Timing[mwkm=MWKMeansAdd[w,dataColor,centroids0,10,0] ];
Print[Style["MWKMeans ",16,Blue],kk,Style["-partition with Ellipsoidal p-clusters:\n",16,Blue],"centroids: ",mwkm[[2]],"  ",Table[Graphics[{RGBColor[mwkm[[2,j]]],Disk[]},ImageSize->20],{j,Length[mwkm[[2]]]}],"\nCLU: ",el=Table[Length[mwkm[[1,j]]],{j,kk}],"--",Total[el],"\nF = ",mwkm[[5]],"; Iteracija=",mwkm[[4]],"; Time = ",time[[1]]];
(*  For graylevel image testing; 
Print["MWKM-B-",kk,mwkm[[2]],"; F=",mwkm[[5]],"; it=",mwkm[[4]], "; CPU=", time[[1]]]; *)
{solGS,centroids0,solColor,mwkm}
]