Skip to content

Commit 715abb7

Browse files
MORGEN is the re-implementation of Dr. Grund's thesis ( first MOLGEN
thesis). Still testing class with randomly selected formulaes.
1 parent 1d6e848 commit 715abb7

File tree

6 files changed

+1661
-427
lines changed

6 files changed

+1661
-427
lines changed

src/main/java/AlgorithmicGroupTheory/HydrogenDistributor.java

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public static int sum(int[] partition, int index) {
116116
return sum;
117117
}
118118

119+
public static int sum(ArrayList<Integer> list, int index) {
120+
int sum=0;
121+
for(int i=0;i<=index;i++) {
122+
sum=sum+list.get(i);
123+
}
124+
return sum;
125+
}
126+
119127
public static int[] setValues(int[] partition, int[] degrees) {
120128
int partitionSize= partition.length;
121129
int[] capacity = new int[partitionSize];
@@ -137,6 +145,27 @@ public static int[] setValues(int[] partition, int[] degrees) {
137145
return capacity;
138146
}
139147

148+
public static int[] setValues(ArrayList<Integer> partition, int[] degrees) {
149+
int partitionSize= partition.size();
150+
int[] capacity = new int[partitionSize];
151+
int[] valences = new int[partitionSize];
152+
int[] totalAtom = new int[partitionSize];
153+
int i=0;
154+
int sum=0;
155+
for(int j=0;j<partitionSize;j++) {
156+
totalAtom[i]=partition.get(i);
157+
sum=sum(partition,i);
158+
valences[i]=degrees[sum-1]-1;
159+
capacity[i]=(degrees[sum-1]-1)*partition.get(i);
160+
i++;
161+
}
162+
163+
HydrogenDistributor.capacity=capacity;
164+
HydrogenDistributor.valences=valences;
165+
HydrogenDistributor.totalAtom=totalAtom;
166+
return capacity;
167+
}
168+
140169
public static int sum(int[] array) {
141170
int sum=0;
142171
for(int i=0;i<array.length;i++) {
@@ -198,7 +227,7 @@ public static List<int[]> combineArrays(LinkedList<List <int[]>> lists) {
198227
* @throws CDKException
199228
*/
200229

201-
public static List<int[]> run(int[] partition,int[] degrees) throws FileNotFoundException, UnsupportedEncodingException, CloneNotSupportedException, CDKException {
230+
/**public static List<int[]> run(int[] partition,int[] degrees) throws FileNotFoundException, UnsupportedEncodingException, CloneNotSupportedException, CDKException {
202231
int partitionSize= partition.length;
203232
int hydrogen= partition[partitionSize-1];
204233
HydrogenDistributor.isotopes=partitionSize-1;
@@ -229,6 +258,39 @@ public static List<int[]> run(int[] partition,int[] degrees) throws FileNotFound
229258
result=distributions;
230259
}
231260
return result;
261+
}**/
262+
263+
public static List<int[]> run(ArrayList<Integer> partition, int[] degrees) throws FileNotFoundException, UnsupportedEncodingException, CloneNotSupportedException, CDKException {
264+
int partitionSize= partition.size();
265+
int hydrogen= partition.get(partitionSize-1);
266+
HydrogenDistributor.isotopes=partitionSize-1;
267+
HydrogenDistributor.size=partitionSize-1;
268+
setValues(partition,degrees);
269+
HydrogenDistributor.totalHydrogen=hydrogen;
270+
List<int[]> result= new ArrayList<int[]>();
271+
if(isotopes==1) {
272+
List<int[]> iarrays= new ArrayList<int[]>();
273+
int[] array = new int[0];
274+
HydrogenDistributor.hydrogens2distribute=totalHydrogen;
275+
distribute(iarrays,totalHydrogen,array,valences[0],totalAtom[0]);
276+
result= iarrays;
277+
}else {
278+
List<int[]> distributions= new ArrayList<int[]>();
279+
for(int[] dene:partition(totalHydrogen,isotopes,0)){
280+
LinkedList<List<int[]>> lists = new LinkedList<List <int[]>>();
281+
for(int i=0;i<dene.length;i++) {
282+
HydrogenDistributor.hydrogens2distribute=dene[i];
283+
List<int[]> iarrays= new ArrayList<int[]>();
284+
int[] array = new int[0];
285+
distribute(iarrays,dene[i],array,valences[i],totalAtom[i]);
286+
lists.add(iarrays);
287+
}
288+
List<int[]> combined=combineArrays(lists);
289+
distributions.addAll(combined);
290+
}
291+
result=distributions;
292+
}
293+
return result;
232294
}
233295

234296
/**

0 commit comments

Comments
 (0)