Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

name: Java CI with Maven - Constrained Optimization Test

on:
# push:
# branches: [ "develop1" ]
# pull_request:
# branches: [ "develop1" ]
workflow_dispatch: # Permette l'avvio manuale dalla tab Actions

jobs:
build:
runs-on: ubuntu-latest

steps:
# Forza il checkout sempre sul branch develop1
- uses: actions/checkout@v4
# with:
# ref: develop1

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build and Test Constrained Nonlinear Vector
# Spiegazione dei parametri:
# -pl hipparchus-optim: si concentra sul modulo optimization
# -am: compila le dipendenze necessarie (come hipparchus-core)
# -Dtest="...": esegue solo i test nel package dei vincoli (constrained)
# -Dsurefire.failIfNoSpecifiedTests=false: evita l'errore se un modulo (es. core) non ha test in quel package
run: >
mvn -B -U -f pom.xml test
-pl hipparchus-optim
-am
-Dtest="org.hipparchus.optim.nonlinear.vector.constrained.**"
-Dsurefire.failIfNoSpecifiedTests=false

- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
39 changes: 12 additions & 27 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
name: Java CI with Maven
name: Hipparchus Optim Test (My Fork)

on: [ push ]
on: [ push, pull_request ]

jobs:
build:
name: Build
name: Build and Test Optimization
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
- name: Build with Maven
run: mvn -B -U -f pom.xml install checkstyle:checkstyle
- name: SonarQube scan
run: |
export PROJECT_NAME="Hipparchus ($GITHUB_REPOSITORY)"
export PROJECT_KEY=${GITHUB_REPOSITORY/\//:}
mvn -B -f pom.xml sonar:sonar \
-Dsonar.host.url=$SONARQUBE_HOST_URL \
-Dsonar.login=$SONARQUBE_TOKEN \
-Dsonar.branch.name=${GITHUB_REF##*/} \
-Dsonar.projectName="$PROJECT_NAME" \
-Dsonar.projectKey="$PROJECT_KEY" \
-Dsonar.qualitygate.wait=true
env:
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONARQUBE_HOST_URL: ${{ vars.SONARQUBE_HOST_URL }}
- name: Deployment
if: ( github.repository == 'Hipparchus-Math/hipparchus' ) && ( ( github.ref == 'refs/heads/develop' ) || startsWith( github.ref, 'refs/heads/release-' ) )
run: mvn -B -U -f pom.xml -s .CI/maven-settings.xml deploy -DskipTests=true -Prelease,ci-deploy
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
cache: 'maven'

- name: Test Optimization Module
# Usiamo -U per forzare l'aggiornamento delle dipendenze (come nell'originale)
# Usiamo -pl e -am per isolare il modulo optimization
run: mvn -B -U -f pom.xml test -pl hipparchus-optim -am

29 changes: 29 additions & 0 deletions hipparchus-optim/nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>test</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>test</goal>
</goals>
<properties>
<hipparchus.debug.sqp>false</hipparchus.debug.sqp>
</properties>
</action>
<action>
<actionName>test.single</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-test-classes</goal>
<goal>surefire:test</goal>
</goals>
<properties>
<test>${packageClassName}</test>
<hipparchus.debug.sqp>true</hipparchus.debug.sqp>
</properties>
</action>
</actions>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public abstract class BaseMultivariateOptimizer<P>
extends BaseOptimizer<P> {
/** Initial guess. */
private double[] start;
public double[] start;
/** Lower bounds. */
private double[] lowerBound;
/** Upper bounds. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hipparchus.linear.EigenDecompositionSymmetric;
import org.hipparchus.optim.LocalizedOptimFormats;
import org.hipparchus.optim.OptimizationData;
import org.hipparchus.optim.SimpleBounds;
import org.hipparchus.optim.nonlinear.scalar.ObjectiveFunction;
import org.hipparchus.util.MathUtils;

Expand Down Expand Up @@ -49,7 +50,10 @@ public abstract class AbstractSQPOptimizer2 extends ConstraintOptimizer {

/** Inequality constraint (may be null). */
private BoundedConstraint boxConstraint;


/** Simple Bounds (may be null). */
private SimpleBounds simpleBounds;

/** Default QPSolver. */
private QPOptimizer QPSolver = new QPDualActiveSolver();

Expand Down Expand Up @@ -102,6 +106,13 @@ public InequalityConstraint getIqConstraint() {
public BoundedConstraint getBoxConstraint() {
return boxConstraint;
}

/** Getter for simple bounds.
* @return simple bounds
*/
public SimpleBounds getSimpleBounds() {
return simpleBounds;
}

/** Getter for QP Solver.
* @return QP Solver
Expand All @@ -120,6 +131,21 @@ public void parseOptimizationData(OptimizationData... optData) {
super.parseOptimizationData(optData);
for (OptimizationData data : optData) {

if (data instanceof SQPProblem) {
SQPProblem problem = (SQPProblem) data;
obj = new SQPObj(problem);

eqConstraint= (problem.hasEquality())?new SQPEq((SQPProblem) data):null;
iqConstraint= (problem.hasInequality())?new SQPIneq((SQPProblem) data):null;

double[] lb = ((SQPProblem) data).getBoxConstraintLB();
double[]ub = ((SQPProblem) data).getBoxConstraintUB();
simpleBounds = (problem.hasBounds())?new SimpleBounds(lb,ub):null;

start=(problem.hasInitialGuess())?problem.getInitialGuess():null;
continue;
}

if (data instanceof ObjectiveFunction) {
obj = (TwiceDifferentiableFunction) ((ObjectiveFunction) data).getObjectiveFunction();
continue;
Expand All @@ -138,6 +164,11 @@ public void parseOptimizationData(OptimizationData... optData) {
boxConstraint = (BoundedConstraint) data;
continue;
}

if (data instanceof SimpleBounds) {
simpleBounds = (SimpleBounds) data;
continue;
}

if (data instanceof SQPOption) {
settings = (SQPOption) data;
Expand Down
Loading
Loading