$darkmode
DENOPTIM
Variable.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2022 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.fitness;
20
21import java.util.ArrayList;
22import java.util.Arrays;
23
24import org.openscience.cdk.qsar.IDescriptor;
25
41public class Variable
42{
47 private String varName;
48
52 private String descName;
53
57 protected ArrayList<String> smarts;
58
63 protected String[] params;
64
65//------------------------------------------------------------------------------
66
71 public Variable(String varName)
72 {
73 this.varName = varName;
74 }
75
76//------------------------------------------------------------------------------
77
91 public static Variable atomSpecific(String varName, String descName,
92 String smartsIdentifier)
93 {
94 ArrayList<String> smarts = new ArrayList<String>(Arrays.asList(
95 smartsIdentifier.split("\\s+")));
96 Variable v = new Variable(varName);
99 return v;
100 }
101
102//------------------------------------------------------------------------------
103
116 public static Variable parametrized(String varName, String descName,
117 String paramsStr)
118 {
119 Variable v = new Variable(varName);
121 v.setDescriptorParameters(paramsStr.split(", +"));
122 return v;
123 }
124
125//------------------------------------------------------------------------------
126
132 public String getName()
133 {
134 return varName;
135 }
136
137//------------------------------------------------------------------------------
138
143 public String getDescriptorName()
144 {
145 return descName;
146 }
147
148//------------------------------------------------------------------------------
149
154 public void setDescriptorName(String descName)
155 {
156 this.descName = descName;
157 }
158
159//------------------------------------------------------------------------------
160
165 public void setSMARTS(ArrayList<String> smarts)
166 {
167 this.smarts = smarts;
168 }
169
170//------------------------------------------------------------------------------
171
178 public void setDescriptorParameters(String[] params)
179 {
180 this.params = params;
181 }
182
183//------------------------------------------------------------------------------
184
188 public String toString()
189 {
190 String s = "Variable [varName:"+varName+", descName:"+descName
191 +", smarts:"+smarts+", pararams:";
192 if (params == null)
193 {
194 s = s + "null";
195 } else {
196 s = s + "[";
197 for (int i=0; i<(params.length-1); i++)
198 s = s + params[i] + ", ";
199 s = s + params[params.length-1] + "]";
200 }
201 s = s + "]";
202 return s;
203 }
204
205//------------------------------------------------------------------------------
206
207}
A variable in the expression defining the fitness.
Definition: Variable.java:42
String[] params
Definition of custom parameters for the configuration of the descriptor implementation.
Definition: Variable.java:63
static Variable atomSpecific(String varName, String descName, String smartsIdentifier)
Returns an atom specific variable, i.e., a variable the value of which needs to be obtained from the ...
Definition: Variable.java:91
ArrayList< String > smarts
SMARTS strings used to select atom/bond specific values.
Definition: Variable.java:57
String getName()
Get the name of this variable, i.e., the string used in the fitness-defining expression.
Definition: Variable.java:132
void setDescriptorParameters(String[] params)
Set the list of strings defining customisable parameter for the descriptor implementation.
Definition: Variable.java:178
Variable(String varName)
Constructs a named variable.
Definition: Variable.java:71
String descName
The short name of the descriptor implementation.
Definition: Variable.java:52
void setSMARTS(ArrayList< String > smarts)
Set the list of smarts used to identify atom/bond-specific values.
Definition: Variable.java:165
String toString()
Returns a human readable string.
Definition: Variable.java:188
String getDescriptorName()
Get the short name of the descriptor implementation.
Definition: Variable.java:143
String varName
The string used to represent this variable in the fitness defining expression.
Definition: Variable.java:47
static Variable parametrized(String varName, String descName, String paramsStr)
Returns an parameterized variable, i.e., a variable the value of which needs to be obtained from the ...
Definition: Variable.java:116
void setDescriptorName(String descName)
Set the short name of the descriptor implementation.
Definition: Variable.java:154