19package denoptim.logging;
21import java.util.HashMap;
22import java.util.concurrent.atomic.AtomicInteger;
23import java.util.logging.Level;
24import java.util.logging.Logger;
26import denoptim.exception.DENOPTIMException;
27import denoptim.io.DenoptimIO;
36public class Monitor extends HashMap<CounterID,AtomicInteger>
46 public String
name =
"noname";
79 private final String
NL = System.getProperty(
"line.separator");
91 this.put(cid,
new AtomicInteger());
122 this.
get(cid).addAndGet(value);
133 if (!dump.equals(
""))
141 "Unable to print monitor report: "+e.getMessage() +
NL
142 +
"Monitor report: " +
NL + dump);
204 StringBuilder sb =
new StringBuilder();
205 sb.append(
"RecordType MonitorName Generation ");
210 sb.append(cid).append(
" ");
213 return sb.toString();
225 StringBuilder sb =
new StringBuilder();
226 sb.append(prefix).append(
" ");
227 sb.append(
name).append(
" ");
233 sb.append(this.
get(cid).get()).append(
" ");
236 return sb.toString();
Utility methods for input/output.
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
A collection of counters user to count actions taken by the evolutionary algorithm.
String name
A name that allows humans to understand what this is a monitor of.
void decreaseBy(CounterID cid, int value)
int dumpStep
Number of steps (i.e., attempts to make new candidates) after which we dump data to file,...
Monitor()
Creates an unnamed monitor.
String monitorFile
Pathname to a file where to dump data.
void increase(CounterID cid)
void increaseBy(CounterID cid, int value)
void decrease(CounterID cid)
int dumpsId
Counter controlling dumps.
String getMonitorDataHeader()
Build a string with the names of all counters.
void printSnapshot(String snapshot)
Logger logger
Logger to use.
String getMonitorDataLine(String prefix)
Build a string with the value of all counters.
static final long serialVersionUID
Version UID.
Monitor(String identifier, int genId, String monitorFile, int dumpStep, boolean dumpData, Logger logger)
Creates a named monitor that is marked with the given generation number.
void changeBy(CounterID cid, int value)
int generationId
A generation number.
void printHeader(String pathName)
boolean dumpData
Flag requesting to dump the monitor data on file.