Open grumpyinca opened 2 years ago
Today's discussion touched on a number of numeric issues and led to #764.
It seems that it will be appropriate to make changes in both initialState and include additional division-by-zero protections in eqnset.
For example, in initialState, for OD_Free, Wire_Dia and Coils_T, "validmin": 0.0 needs to change to "validmin": Number.MIN_VALUE and perhaps an "engineering realistic" value that much, much larger.
It was observed that in computing the Objective Value, taking the difference between two extremely small numbers and then squaring the result can produce a value that is outside the floating-point limits.
Background on JavaScript alternatives for handling divide-by-zero: https://stackoverflow.com/questions/8072323/best-way-to-prevent-handle-divide-by-0-in-javascript
Today's discussion raised concern about the use of smallnum in order to mitigate divide-by-zero "corrupting" the design equations. The preferred approach is to validate user input such the risk of divide-by-zero is eliminated.
While conceptually attractive, there are issues:
Examine PCyl & Solid for how they respond to extreme user inputs and determine if they need divide-by-zero mitigation. Perhaps those solutions can be an alternative to the approaches investigated in this branch.
Consider testing Objective Value at the conclusion of Search, Seek and Trade. If not valid (infinity or NaN) put out an appropriate Alert (or pop-up).
Separately, when Search returns without a feasible solution, there may also be an opportunity to guide the user by creating an alert (or pop-up) that asks if it is possible that the design is over-specified.
It has become apparent that the extension spring model has multiple special (a.k.a. "pathological") cases that require further investigation. Specifically, these cases need to be isolated & traced back to a "root cause".
These cases sometimes cause search failures or sometimes cause the search to converge to a point that is OBJ < OBJMIN feasible but is really an invalid spring. Perhaps adjustment in the current validity configuration will be sufficient. Perhaps it will be necessary to make changes in extension spring's eqnset.js.
Areas of concern
WhyPC_SafeDeflectNegative2.json.txt