diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 320ffc4..3c48f59 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '8', '11', '17', '18' ] + java: [ '11', '17', '21', '23' ] steps: - uses: actions/checkout@v2 @@ -37,7 +37,7 @@ jobs: - name: Setup Java uses: actions/setup-java@v1 with: - java-version: 8 + java-version: 11 - name: Build with Gradle run: ./gradlew jacocoTestReport - name: Upload coverage to Codecov diff --git a/README.md b/README.md index 004a6c8..b564d18 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The upstream GitHub project can be found at ## Dependencies ## -The only requirement is Java 8 or later. +The only requirement is Java 11 or later. ## Usage ## @@ -48,7 +48,7 @@ for the following reasons: new bugs that are caused by porting to Java. - **Code Reviews**: - It should be more easy to conduct code reviews since the sources can be compared to the original version. + It should be easier to conduct code reviews since the sources can be compared to the original version. Below follows a slightly modified version of the original README file. diff --git a/build.gradle b/build.gradle index 644703f..6af5d77 100644 --- a/build.gradle +++ b/build.gradle @@ -19,10 +19,15 @@ plugins { group = "de.bwaldvogel" version = '2.44' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + sourceCompatibility = '11' + targetCompatibility = '11' +} -compileJava.options.encoding = 'UTF-8' +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' + options.compilerArgs.addAll(['-Xlint:all', '-Werror']) +} jar { manifest { @@ -90,7 +95,7 @@ publishing { } repositories { maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" + url = "https://oss.sonatype.org/service/local/staging/deploy/maven2" credentials { username = project.hasProperty('nexusUsername') ? project.property('nexusUsername') : System.getenv('NEXUS_USERNAME') password = project.hasProperty('nexusPassword') ? project.property('nexusPassword') : System.getenv('NEXUS_PASSWORD') @@ -128,7 +133,7 @@ test { } wrapper { - gradleVersion = "7.4.1" + gradleVersion = "8.12" distributionType = Wrapper.DistributionType.ALL } @@ -137,7 +142,9 @@ jmh { jvmArgs = ["-Ddataset.directory=" + projectDir + "/src/test/datasets"] } -tasks['jmh'].dependsOn downloadAndVerifyRcv1 +tasks.named('jmh').configure { + dependsOn downloadAndVerifyRcv1 +} dependencies { testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: 'latest.release' diff --git a/buildscript-gradle.lockfile b/buildscript-gradle.lockfile index cc2b715..b463142 100644 --- a/buildscript-gradle.lockfile +++ b/buildscript-gradle.lockfile @@ -1,8 +1,8 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -de.undercouch.download:de.undercouch.download.gradle.plugin:5.1.0=classpath -de.undercouch:gradle-download-task:5.1.0=classpath +de.undercouch.download:de.undercouch.download.gradle.plugin:5.6.0=classpath +de.undercouch:gradle-download-task:5.6.0=classpath me.champeau.gradle.jmh:me.champeau.gradle.jmh.gradle.plugin:0.5.3=classpath me.champeau.gradle:jmh-gradle-plugin:0.5.3=classpath net.sf.jopt-simple:jopt-simple:4.6=classpath diff --git a/gradle.lockfile b/gradle.lockfile index 862002e..faf5ce3 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -1,38 +1,40 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -ch.qos.logback:logback-classic:1.2.11=jmhRuntimeClasspath,testRuntimeClasspath -ch.qos.logback:logback-core:1.2.11=jmhRuntimeClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy-agent:1.12.9=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy:1.12.9=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +ch.qos.logback:logback-classic:1.5.15=jmhRuntimeClasspath,testRuntimeClasspath +ch.qos.logback:logback-core:1.5.15=jmhRuntimeClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.17.1=jmh,jmhCompileClasspath,jmhRuntimeClasspath +commons-io:commons-io:2.16.1=jmh,jmhCompileClasspath,jmhRuntimeClasspath +net.bytebuddy:byte-buddy-agent:1.15.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.15.11=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhRuntimeClasspath -nl.jqno.equalsverifier:equalsverifier:3.10=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-compress:1.21=jmh,jmhCompileClasspath,jmhRuntimeClasspath -org.apache.commons:commons-math3:3.2=jmh,jmhCompileClasspath,jmhRuntimeClasspath +nl.jqno.equalsverifier:equalsverifier:3.18=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-compress:1.27.1=jmh,jmhCompileClasspath,jmhRuntimeClasspath +org.apache.commons:commons-lang3:3.16.0=jmh,jmhCompileClasspath,jmhRuntimeClasspath +org.apache.commons:commons-math3:3.6.1=jmh,jmhCompileClasspath,jmhRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.22.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jacoco:org.jacoco.agent:0.8.7=jacocoAgent,jacocoAnt -org.jacoco:org.jacoco.ant:0.8.7=jacocoAnt -org.jacoco:org.jacoco.core:0.8.7=jacocoAnt -org.jacoco:org.jacoco.report:0.8.7=jacocoAnt -org.junit.jupiter:junit-jupiter-api:5.8.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:5.8.2=jmhRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:5.8.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.8.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.8.2=jmhRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:5.8.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.mockito:mockito-core:4.5.1=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.objenesis:objenesis:3.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.openjdk.jmh:jmh-core:1.35=jmh,jmhCompileClasspath,jmhRuntimeClasspath -org.openjdk.jmh:jmh-generator-annprocess:1.35=jmh,jmhCompileClasspath,jmhRuntimeClasspath +org.assertj:assertj-core:3.27.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jacoco:org.jacoco.agent:0.8.12=jacocoAgent,jacocoAnt +org.jacoco:org.jacoco.ant:0.8.12=jacocoAnt +org.jacoco:org.jacoco.core:0.8.12=jacocoAnt +org.jacoco:org.jacoco.report:0.8.12=jacocoAnt +org.junit.jupiter:junit-jupiter-api:5.11.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:5.11.4=jmhRuntimeClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:5.11.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:1.11.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:1.11.4=jmhRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:5.11.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.mockito:mockito-core:5.14.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.objenesis:objenesis:3.4=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.openjdk.jmh:jmh-core:1.37=jmh,jmhCompileClasspath,jmhRuntimeClasspath +org.openjdk.jmh:jmh-generator-annprocess:1.37=jmh,jmhCompileClasspath,jmhRuntimeClasspath org.openjdk.jmh:jmh-generator-asm:1.25=jmh,jmhCompileClasspath,jmhRuntimeClasspath org.openjdk.jmh:jmh-generator-bytecode:1.25=jmh,jmhCompileClasspath,jmhRuntimeClasspath org.openjdk.jmh:jmh-generator-reflection:1.25=jmh,jmhCompileClasspath,jmhRuntimeClasspath -org.opentest4j:opentest4j:1.2.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.1=jacocoAnt -org.ow2.asm:asm-commons:9.1=jacocoAnt -org.ow2.asm:asm-tree:9.1=jacocoAnt +org.opentest4j:opentest4j:1.3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm-commons:9.7=jacocoAnt +org.ow2.asm:asm-tree:9.7=jacocoAnt org.ow2.asm:asm:5.0.3=jmh,jmhCompileClasspath,jmhRuntimeClasspath -org.ow2.asm:asm:9.1=jacocoAnt -org.slf4j:slf4j-api:1.7.36=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm:9.7=jacocoAnt +org.slf4j:slf4j-api:2.0.16=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath empty=annotationProcessor,compileClasspath,jmhAnnotationProcessor,runtimeClasspath,signatures,testAnnotationProcessor diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d7e66b5..e0fd020 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +200,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +216,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/java/de/bwaldvogel/liblinear/Linear.java b/src/main/java/de/bwaldvogel/liblinear/Linear.java index c8c4577..0fb809b 100644 --- a/src/main/java/de/bwaldvogel/liblinear/Linear.java +++ b/src/main/java/de/bwaldvogel/liblinear/Linear.java @@ -401,6 +401,7 @@ public static Model loadModel(Reader inputReader) throws IOException { * * @deprecated use {@link Linear#loadModel(Path)} instead */ + @Deprecated public static Model loadModel(File modelFile) throws IOException { return loadModel(modelFile.toPath()); } @@ -580,6 +581,7 @@ public static void saveModel(Writer modelOutput, Model model) throws IOException * * @deprecated use {@link Linear#saveModel(Path, Model)} instead */ + @Deprecated public static void saveModel(File modelFile, Model model) throws IOException { saveModel(modelFile.toPath(), model); } @@ -2536,6 +2538,7 @@ public static int getVersion() { * * @deprecated Use {@link Parameter#setRandom(Random)} instead */ + @Deprecated public static void resetRandom() { } } diff --git a/src/main/java/de/bwaldvogel/liblinear/Model.java b/src/main/java/de/bwaldvogel/liblinear/Model.java index 6e39859..6eba91f 100644 --- a/src/main/java/de/bwaldvogel/liblinear/Model.java +++ b/src/main/java/de/bwaldvogel/liblinear/Model.java @@ -246,8 +246,7 @@ private static int arrayHashCode(double[] w) { if (element == -0.0) { element = 0.0; } - long bits = Double.doubleToLongBits(element); - result = 31 * result + (int)(bits ^ (bits >>> 32)); + result = 31 * result + Double.hashCode(element); } return result; } @@ -255,6 +254,7 @@ private static int arrayHashCode(double[] w) { /** * @deprecated use {@link Model#save(Path)} instead */ + @Deprecated public void save(File modelFile) throws IOException { save(modelFile.toPath()); } @@ -276,6 +276,7 @@ public void save(Writer writer) throws IOException { /** * @deprecated use {@link Model#load(Path)} instead */ + @Deprecated public static Model load(File modelFile) throws IOException { return load(modelFile.toPath()); } diff --git a/src/main/java/de/bwaldvogel/liblinear/Problem.java b/src/main/java/de/bwaldvogel/liblinear/Problem.java index 97fddf4..983d766 100644 --- a/src/main/java/de/bwaldvogel/liblinear/Problem.java +++ b/src/main/java/de/bwaldvogel/liblinear/Problem.java @@ -57,6 +57,7 @@ public class Problem { /** * @deprecated use {@link Problem#readFromFile(Path, double)} instead */ + @Deprecated public static Problem readFromFile(File file, double bias) throws IOException, InvalidInputDataException { return readFromFile(file.toPath(), bias); } @@ -71,6 +72,7 @@ public static Problem readFromFile(Path path, double bias) throws IOException, I /** * @deprecated use {@link Problem#readFromFile(Path, Charset, double)} instead */ + @Deprecated public static Problem readFromFile(File file, Charset charset, double bias) throws IOException, InvalidInputDataException { return readFromFile(file.toPath(), charset, bias); } diff --git a/src/main/java/de/bwaldvogel/liblinear/Train.java b/src/main/java/de/bwaldvogel/liblinear/Train.java index c80a8ba..8489d1e 100644 --- a/src/main/java/de/bwaldvogel/liblinear/Train.java +++ b/src/main/java/de/bwaldvogel/liblinear/Train.java @@ -287,6 +287,7 @@ public void parse_command_line(String argv[]) { * @throws InvalidInputDataException if the input file is not correctly formatted * @deprecated use {@link Train#readProblem(Path, double)} instead */ + @Deprecated public static Problem readProblem(File file, double bias) throws IOException, InvalidInputDataException { return readProblem(file.toPath(), bias); } @@ -305,6 +306,7 @@ public static Problem readProblem(Path path, double bias) throws IOException, In /** * @deprecated use {@link Train#readProblem(Path, Charset, double)} instead */ + @Deprecated public static Problem readProblem(File file, Charset charset, double bias) throws IOException, InvalidInputDataException { return readProblem(file.toPath(), charset, bias); } diff --git a/src/test/java/de/bwaldvogel/liblinear/RegressionTest.java b/src/test/java/de/bwaldvogel/liblinear/RegressionTest.java index 4b1cd8d..f1e6b30 100644 --- a/src/test/java/de/bwaldvogel/liblinear/RegressionTest.java +++ b/src/test/java/de/bwaldvogel/liblinear/RegressionTest.java @@ -70,6 +70,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.84184; case 1: return regularizeBias ? 0.84552 : 0.84414; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L2LOSS_SVC_DUAL: switch (bias) { @@ -77,6 +79,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.84368; case 1: return 0.85241; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L2LOSS_SVC: switch (bias) { @@ -84,6 +88,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.84276; case 1: return regularizeBias ? 0.85057 : 0.85149; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L1LOSS_SVC_DUAL: switch (bias) { @@ -91,6 +97,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.83494; case 1: return 0.83402; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case MCSVM_CS: switch (bias) { @@ -98,6 +106,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.8377; case 1: return 0.83862; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L1R_L2LOSS_SVC: switch (bias) { @@ -105,6 +115,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.8478; case 1: return regularizeBias ? 0.8478 : 0.84782; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L1R_LR: switch (bias) { @@ -112,6 +124,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.8473; case 1: return regularizeBias ? 0.84782 : 0.84598; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_LR_DUAL: switch (bias) { @@ -119,7 +133,11 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.8423; case 1: return 0.8492; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } + default: + throw new IllegalArgumentException("Unexpected solverType: " + solverType); } case "dna.scale": switch (solverType) { @@ -129,12 +147,16 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.94941; case 1: return regularizeBias ? 0.950253 : 0.951096; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L2LOSS_SVC_DUAL: switch (bias) { case -1: case 1: return 0.9452; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L2LOSS_SVC: switch (bias) { @@ -142,6 +164,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.94941; case 1: return 0.95194; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_L1LOSS_SVC_DUAL: switch (bias) { @@ -149,6 +173,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.94688; case 1: return 0.94604; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case MCSVM_CS: switch (bias) { @@ -156,6 +182,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.9292; case 1: return 0.92749; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L1R_L2LOSS_SVC: switch (bias) { @@ -163,6 +191,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.9553; case 1: return regularizeBias ? 0.956998 : 0.95363; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L1R_LR: switch (bias) { @@ -170,6 +200,8 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.9536; case 1: return regularizeBias ? 0.95194 : 0.95278; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } case L2R_LR_DUAL: switch (bias) { @@ -177,7 +209,11 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType, return 0.9486; case 1: return 0.94941; + default: + throw new IllegalArgumentException("Unexpected bias: " + bias); } + default: + throw new IllegalArgumentException("Unexpected solverType: " + solverType); } default: throw new IllegalArgumentException("Unknown expectation: " + dataset + ", " + solverType + ", " + bias);