-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extra options specific to a solver
'--extra <filepath>' option is introduced. This gives the path to a json file containing a dictionary. This dictionary sets values for options that are specific to a particular solver. For instance, one extra option is introduced for defoCP and SRLS. This argument controls the maximum number of intermediate segments that these solvers can use. This fixes Issue #7
- Loading branch information
Showing
14 changed files
with
184 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package edu.repetita.settings; | ||
|
||
import edu.repetita.core.Setting; | ||
|
||
import java.util.*; | ||
|
||
public class SRSetting extends Setting { | ||
|
||
private int maxSeg = 1; | ||
|
||
public int getMaxSeg() { | ||
return maxSeg; | ||
} | ||
|
||
public void setMaxSeg(int maxSeg) { | ||
this.maxSeg = maxSeg; | ||
} | ||
|
||
@Override | ||
public void help(HashMap<String, String> args) { | ||
args.put("maxseg", "The maximum number of intermediate segments (i.e., source and destination nodes are not counted)"); | ||
} | ||
|
||
@Override | ||
protected void setExtra(String key, Object value) throws IllegalArgumentException { | ||
switch (key) { | ||
case "maxseg": | ||
if (!(value instanceof Integer)) { | ||
throw new IllegalArgumentException("The maximum number of intermediate segments should be an integer."); | ||
} | ||
int maxSeg = (Integer) value; | ||
if (maxSeg < 0) { | ||
throw new IllegalArgumentException("'" + value + "' is not a valid number of segment." + | ||
" It should be positive."); | ||
} | ||
this.maxSeg = maxSeg; | ||
break; | ||
default: | ||
super.setExtra(key, value); | ||
} | ||
} | ||
|
||
@Override | ||
public Setting clone() { | ||
Setting copy = new SRSetting(); | ||
this.init(copy); | ||
return copy; | ||
} | ||
|
||
@Override | ||
protected void init(Setting copy) { | ||
super.init(copy); | ||
((SRSetting) copy).setMaxSeg(maxSeg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.