@@ -203,7 +203,7 @@ def fun_sphere(self, X: np.ndarray, fun_control: Optional[Dict] = None) -> np.nd
203203 return y
204204
205205 def fun_cubed (self , X : np .ndarray , fun_control : Optional [Dict ] = None ) -> np .ndarray :
206- """Cubed function.
206+ """Cubed function. Implements the function f(x) = sum((x_i - offset)^3).
207207
208208 Args:
209209 X (array):
@@ -217,10 +217,10 @@ def fun_cubed(self, X: np.ndarray, fun_control: Optional[Dict] = None) -> np.nda
217217 Examples:
218218 >>> from spotpython.fun.objectivefunctions import analytical
219219 >>> import numpy as np
220- >>> X = np.array([[1, 2, 3], [4, 5, 6]])
220+ >>> X = np.array([[1, 2, 3], [4, 5, 6], [-1, -1, -1] ])
221221 >>> fun = analytical()
222222 >>> fun.fun_cubed(X)
223- array([ 0 ., 27 .])
223+ array([ 36 ., 405., -3 .])
224224 """
225225
226226 if fun_control is None :
@@ -455,36 +455,6 @@ def fun_sin_cos(self, X, fun_control=None):
455455 else :
456456 return y
457457
458- # def fun_forrester_2(self, X):
459- # """
460- # Function used by [Forr08a, p.83].
461- # f(x) = (6x- 2)^2 sin(12x-4) for x in [0,1].
462- # Starts with three sample points at x=0, x=0.5, and x=1.
463-
464- # Args:
465- # X (flooat): input values (1-dim)
466-
467- # Returns:
468- # float: function value
469- # """
470- # try:
471- # X.shape[1]
472- # except ValueError:
473- # X = np.array(X)
474-
475- # X = np.atleast_2d(X)
476- # # y = X[:, 1]
477- # y = (6.0 * X - 2) ** 2 * np.sin(12 * X - 4)
478- # if self.sigma != 0:
479- # noise_y = np.array([], dtype=float)
480- # for i in y:
481- # noise_y = np.append(
482- # noise_y, i + np.random.normal(loc=0, scale=self.sigma, size=1)
483- # )
484- # return noise_y
485- # else:
486- # return y
487-
488458 def fun_runge (self , X : np .ndarray , fun_control : Optional [Dict ] = None ) -> np .ndarray :
489459 """Runge function. Formula: f(x) = 1/ (1 + sum(x_i) - offset)^2. Dim: k >= 1.
490460 Interval: -5 <= x <= 5
@@ -522,39 +492,61 @@ def fun_runge(self, X: np.ndarray, fun_control: Optional[Dict] = None) -> np.nda
522492 return y
523493
524494 def fun_wingwt (self , X : np .ndarray , fun_control : Optional [Dict ] = None ) -> np .ndarray :
525- r"""Wing weight function. Example from Forrester et al. to understand the weight
526- of an unpainted light aircraft wing as a function of nine design and operational parameters:
527- $W=0.036 S_W^{0.758} Wfw^{0.0035} ( A / (\cos^2 \Lambda))^{0.6} q^{0.006} \lambda^{0.04} ( (100 Rtc)/(\cos
528- \Lambda) ))^{-0.3} (Nz Wdg)^{0.49}$
495+ r"""Wing weight function.
496+ Calculate the weight of an unpainted light aircraft wing based on design and operational parameters.
497+ This function implements the wing weight model from Forrester et al., which aims to predict
498+ the wing weight \( W \) using the following formula:
499+
500+ \[
501+ W = 0.036 \times S_W^{0.758} \times W_{fw}^{0.0035} \times \left( \frac{A}{\cos^2 \Lambda} \right)^{0.6} \times q^{0.006} \times \lambda^{0.04} \times \left( \frac{100 \times R_{tc}}{\cos \Lambda} \right)^{-0.3} \times (N_z \times W_{dg})^{0.49} + S_W \times W_p
502+ \]
503+
504+ where:
505+
506+ - \( S_W \): Wing area \((\text{ft}^2)\)
507+ - \( W_{fw} \): Weight of fuel in the wing (lb)
508+ - \( A \): Aspect ratio
509+ - \( \Lambda \): Quarter-chord sweep (degrees)
510+ - \( q \): Dynamic pressure at cruise \((\text{lb/ft}^2)\)
511+ - \( \lambda \): Taper ratio
512+ - \( R_{tc} \): Aerofoil thickness to chord ratio
513+ - \( N_z \): Ultimate load factor
514+ - \( W_{dg} \): Flight design gross weight (lb)
515+ - \( W_p \): Paint weight \((\text{lb/ft}^2)\)
516+
517+ Parameter Overview:
529518
530519 | Symbol | Parameter | Baseline | Minimum | Maximum |
531520 |-----------|----------------------------------------|----------|---------|---------|
532- | $ S_W$ | Wing area ($ft^2$ ) | 174 | 150 | 200 |
533- | $ W_{fw}$ | Weight of fuel in wing (lb) | 252 | 220 | 300 |
534- | $A$ | Aspect ratio | 7.52 | 6 | 10 |
535- | $\ Lambda$ | Quarter-chord sweep (deg) | 0 | -10 | 10 |
536- | $q$ | Dynamic pressure at cruise ($ lb/ft^2$ ) | 34 | 16 | 45 |
537- | $\ lambda$ | Taper ratio | 0.672 | 0.5 | 1 |
538- | $ R_{tc}$ | Aerofoil thickness to chord ratio | 0.12 | 0.08 | 0.18 |
539- | $ N_z$ | Ultimate load factor | 3.8 | 2.5 | 6 |
540- | $ W_{dg}$ | Flight design gross weight (lb) | 2000 | 1700 | 2500 |
541- | $ W_p$ | paint weight ( lb/ft^2) | 0.064 | 0.025 | 0.08 |
521+ | \( S_W \) | Wing area \((\text{ft}^2)\ ) | 174 | 150 | 200 |
522+ | \( W_{fw} \) | Weight of fuel in wing (lb) | 252 | 220 | 300 |
523+ | \( A \) | Aspect ratio | 7.52 | 6 | 10 |
524+ | \( \ Lambda \) | Quarter-chord sweep (deg) | 0 | -10 | 10 |
525+ | \( q \) | Dynamic pressure at cruise \((\text{ lb/ft}^2)\ ) | 34 | 16 | 45 |
526+ | \( \ lambda \) | Taper ratio | 0.672 | 0.5 | 1 |
527+ | \( R_{tc} \) | Aerofoil thickness to chord ratio | 0.12 | 0.08 | 0.18 |
528+ | \( N_z \) | Ultimate load factor | 3.8 | 2.5 | 6 |
529+ | \( W_{dg} \) | Flight design gross weight (lb) | 2000 | 1700 | 2500 |
530+ | \( W_p \) | Paint weight \((\text{ lb/ft} ^2)\) | 0.064 | 0.025 | 0.08 |
542531
543532 Args:
544- X (array): input
545- fun_control (dict): dict with entries `sigma` (noise level) and `seed` (random seed).
533+ X (np.ndarray):
534+ A 2D numpy array where each row contains 10 parameters for which the wing weight will be calculated.
535+ fun_control (Optional[Dict]):
536+ A dictionary with keys `sigma` (noise level) and `seed` (random seed)
537+ for incorporating randomness if required. Default is `None`.
546538
547539 Returns:
548- np.ndarray: A 1D numpy array with shape (n,) containing the calculated values.
540+ np.ndarray:
541+ A 1D numpy array with shape (n,) containing the calculated wing weight values.
549542
550543 Examples:
551544 >>> from spotpython.fun.objectivefunctions import analytical
552545 >>> import numpy as np
553- >>> X = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10, 11, 12] ])
546+ >>> X = np.array([np.zeros(10), np.ones(10) ])
554547 >>> fun = analytical()
555548 >>> fun.fun_wingwt(X)
556- array([0.0625 , 0.015625 , 0.00390625])
557-
549+ array([158.28245046, 409.33182691])
558550 """
559551 if fun_control is None :
560552 fun_control = self .fun_control
0 commit comments