19package denoptim.utils;
22import java.text.DecimalFormat;
23import java.text.NumberFormat;
24import java.util.Collections;
25import java.util.Iterator;
27import java.util.Locale;
30import denoptim.constants.DENOPTIMConstants;
39 private static Runtime
RUNTIME = Runtime.getRuntime();
53 return String.format(
"%0" + count +
"d", number);
63 NumberFormat format = NumberFormat.getInstance();
64 StringBuilder sb =
new StringBuilder();
65 long maxMemory =
RUNTIME.maxMemory();
66 long allocatedMemory =
RUNTIME.totalMemory();
67 long freeMemory =
RUNTIME.freeMemory();
68 sb.append(
"Free memory: ");
69 sb.append(format.format(freeMemory / 1024));
71 sb.append(
"Allocated memory: ");
72 sb.append(format.format(allocatedMemory / 1024));
74 sb.append(
"Max memory: ");
75 sb.append(format.format(maxMemory / 1024));
77 sb.append(
"Total free memory: ");
78 sb.append(format.format((freeMemory + (maxMemory - allocatedMemory))
82 System.out.println(sb.toString());
98 String openingSing =
"";
99 String closingSign =
")";
118 for (
int i=0; i<s.length(); i++)
120 String ss = s.substring(i);
121 if (ss.startsWith(closingSign))
133 else if (ss.startsWith(openingSing))
151 Iterator<Set<T>> iterator = list.iterator();
155 while (prevSize > currentSize)
157 prevSize = list.size();
158 while (iterator.hasNext())
160 Set<T> setA = iterator.next();
161 Iterator<Set<T>> innerIterator = list.iterator();
162 while (innerIterator.hasNext())
164 Set<T> setB = innerIterator.next();
167 if (!Collections.disjoint(setA,setB))
175 currentSize = list.size();
191 int decimals,
double value)
193 NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
194 DecimalFormat df = (DecimalFormat) nf;
195 df.applyPattern(pattern);
196 df.setMinimumFractionDigits(decimals);
197 return df.format(value);
General set of constants used in DENOPTIM.
static final String EOL
new line character
static String getEnglishFormattedDecimal(String pattern, int decimals, double value)
Formats a decimal number using the given pattern but with English format as for separators.
static String getEnglishFormattedDecimal(String pattern, double value)
Formats a decimal number using the given pattern but with English format as for separators.
static void printMemoryDetails()
Print an analysis of the current memory usage.
static String getPaddedString(int count, int number)
returns the padded string with zeroes placed to the left of 'number' up to reach the desired number o...
static int getIdxOfClosing(int id, String s)
Return the index of the closing parenthesis.
static< T > void unionOfIntersectingSets(List< Set< T > > list)
Takes the union of any two sets in this list that intersect.