$darkmode
DENOPTIM
FitnessRunner.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.programs.fitnessevaluator;
20
21import java.io.File;
22
23import denoptim.programs.combinatorial.FragSpaceExplorer;
24import denoptim.programs.denovo.GARunner;
25import denoptim.task.ProgramTask;
26
27
38public class FitnessRunner extends ProgramTask
39{
40 private FPRunner runner = null;
41
42//------------------------------------------------------------------------------
43
49 public FitnessRunner(File configFile, File workDir)
50 {
51 super(configFile, workDir);
52 }
53
54//------------------------------------------------------------------------------
55
56 @Override
57 public void runProgram() throws Throwable
58 {
59 FRParameters frParams = new FRParameters();
60
61 if (workDir != null)
62 {
63 frParams.setWorkDirectory(workDir.getAbsolutePath());
64 }
65
66 frParams.readParameterFile(configFilePathName.getAbsolutePath());
67 frParams.checkParameters();
68 frParams.processParameters();
69 frParams.startProgramSpecificLogger(loggerIdentifier, false); //toSTDOUT
70 frParams.printParameters();
71
72 runner = new FPRunner(frParams);
73 runner.run();
74 }
75
76//------------------------------------------------------------------------------
77
78 protected void handleThrowable()
79 {
80 if (runner != null)
81 {
83 }
84 super.handleThrowable();
85 }
86
87//------------------------------------------------------------------------------
88}
Logger startProgramSpecificLogger(String loggerIdentifier)
Starts a logger with the given name.
void readParameterFile(String infile)
Read the parameter TXT file line by line and interpret its content.
void printParameters()
Print all parameters.
void setWorkDirectory(String pathname)
Gets the pathname to the working directory.
Runs a fitness provider task as defined in the static parameters.
Definition: FPRunner.java:57
void run()
Create and run the fitness task.
Definition: FPRunner.java:171
void stopRun()
Stops all subtasks and shutdown executor.
Definition: FPRunner.java:158
Parameters controlling execution of FitnessRunner.
void checkParameters()
Evaluate consistency of input parameters.
void processParameters()
Processes all parameters and initialize related objects.
void handleThrowable()
Method to handle any Throwable originated from the runProgram() method.
FitnessRunner(File configFile, File workDir)
Creates and configures the program task.
Task structure for any of the main programs in the denoptim project, such as genetic algorithm and co...
String loggerIdentifier
Identifier of this program's logger.
File configFilePathName
File containing configuration parameters for the program task.
File workDir
The file system location where we want to be placed when doing the work.
Definition: Task.java:78