MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / get

Function get

pymoo/core/variable.py:250–283  ·  view source on GitHub ↗

Get decision variable values from a tuple of Variable objects. Args: args: Tuple of Variable or objects. size: Size to reshape decision variables. kwargs: Additional keyword arguments for get method. Returns: Decision variable value(s).

(
    *args: Tuple[Union[Variable, object], ...],
    size: Optional[Union[tuple, int]] = None,
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

248
249
250def get(
251 *args: Tuple[Union[Variable, object], ...],
252 size: Optional[Union[tuple, int]] = None,
253 **kwargs: Any,
254) -> Union[tuple, object, None]:
255 """Get decision variable values from a tuple of Variable objects.
256
257 Args:
258 args: Tuple of Variable or objects.
259 size: Size to reshape decision variables.
260 kwargs: Additional keyword arguments for get method.
261
262 Returns:
263 Decision variable value(s).
264 """
265 if len(args) == 0:
266 return None
267
268 ret = []
269 for arg in args:
270 v = arg.get(**kwargs) if isinstance(arg, Variable) else arg
271
272 if size is not None:
273 if isinstance(v, np.ndarray):
274 v = np.reshape(v, size)
275 else:
276 v = np.full(size, v)
277
278 ret.append(v)
279
280 if len(ret) == 1:
281 return ret[0]
282 else:
283 return tuple(ret)

Callers 15

_doMethod · 0.90
_doMethod · 0.90
_doMethod · 0.90
_doMethod · 0.90
_doMethod · 0.90
_doMethod · 0.90
doMethod · 0.90
doMethod · 0.90
get_prob_varMethod · 0.90
_doMethod · 0.90
doMethod · 0.90
_initialize_infillMethod · 0.90

Calls 2

appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected