From 896587bed18a8fb7d0cf6b3ffcc493110942475e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:47:16 +0000 Subject: [PATCH] Fix: Improve robustness and correctness of EBEs analysis This commit addresses several critical issues in the EBEs.java file to improve the stability, correctness, and maintainability of the structural analysis and optimization code. - Fixes a bug in getNumberOfConstraintsNodes() that returned an incorrect value. - Prevents division-by-zero errors in stiffness matrix calculations by handling near-zero length elements. - Improves exception handling during file I/O to prevent NullPointerExceptions on file read errors. - Removes a line that incorrectly set small element lengths to zero. --- jmetal4.5.2/src/jmetal/problems/EBEs.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jmetal4.5.2/src/jmetal/problems/EBEs.java b/jmetal4.5.2/src/jmetal/problems/EBEs.java index 1c97eb6..f95aea1 100644 --- a/jmetal4.5.2/src/jmetal/problems/EBEs.java +++ b/jmetal4.5.2/src/jmetal/problems/EBEs.java @@ -188,7 +188,7 @@ public void setNumberOfConstraintsNodes(int numberOfConstraintsNodes) { } // set numberOfConstraintsNodes public int getNumberOfConstraintsNodes() { - return numberOfWeigthHypothesis_ ; + return numberOfConstraintsNodes_ ; } // get numberOfRestrictionNodes /** @@ -2277,6 +2277,17 @@ public void EBEsMat3DL_iRig_jRig(int e) throws JMException{ double E=Groups_[idx][E_]; // elastic transversal modulus double G=Groups_[idx][G_]; + if (Math.abs(Lij) < 1e-9) { + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { + Kii[i][j] = 0; + Kij[i][j] = 0; + Kji[i][j] = 0; + Kjj[i][j] = 0; + } + } + return; + } // esfuerzos en nudo j por reacción de desplazamientos en i + esfuerzo en i Kii[0][0] = E * S / Lij; Kii[0][1] = 0; @@ -4687,7 +4698,7 @@ public String EBEsReadProblems() { input.close(); } catch (Exception ex) { - System.out.println("Error: data file EBEs not readed"); + throw new RuntimeException("Error: data file EBEs not readed", ex); } return txt; @@ -4911,7 +4922,6 @@ public final void EBEsReadDataFile(String fileName) throws JMException{ yj = Node_[nj][aY_]; zj = Node_[nj][aZ_]; Element_[i][L_]=Math.sqrt(Math.pow((xj - xi), 2.0) + Math.pow((yj - yi), 2.0) + Math.pow((zj - zi), 2.0)); - if(Element_[i][L_] < 0.001) Element_[i][L_] = 0.0; } txt=input.nextLine(); txt=input.nextLine(); @@ -4956,7 +4966,7 @@ public final void EBEsReadDataFile(String fileName) throws JMException{ input.close(); } catch (Exception ex) { - System.out.println("Error: data file EBEs not readed"); + throw new RuntimeException("Error: data file EBEs not readed", ex); } }