osier.utils.n_mga#

osier.utils.n_mga(results_obj, n_points=10, slack=0.1, sense='minimize', how='farthest', seed=1234, metric='euclidean', start_idx=None, wide_form=False)[source]#

N-dimensional modeling-to-generate-alternatives (n-mga) allows users to efficiently search decision space by relaxing the objective function(s) by a specified amount of slack. This implementation will identify all points inside of an N-polytope (a polygon in N-dimensions). Then a reduced subset of points will be selected.

The algorithm is:

  1. Generate a near-optimal front based on the given slack values.

  2. Loop through each point in the model’s history.

  3. Add each point to a set of checked points to prevent repeated calculations.

  4. Check if a point is inside the N-polytope bounded by the Pareto and

    near-optimal fronts.

  5. Select a subset of points based on a random selection or with a farthest first traversal.

Parameters:
  • results_obj (:class:pymoo.Result) – The simulation results object containing all data and metadata.

  • n_points (int or str) – The number of points to select from the near-optimal region. Default is 10. The only accepted string value is ‘all’, which will return all values in the near-optimal space.

  • slack (float or list of float) – The slack value for the sub-optimal front, expressed as a decimal percentage. If float is passed, the same slack will be applied to all objectives. A list of slack values should have the same length as the list of objectives. The slack will be applied to objective with the same index (defined when users initialized the osier.CapacityExpansion problem).

  • sense (str) – Indicates whether the optimization was a minimization or maximization. If min, the sub-optimal front is greater than the Pareto front. If max, the sub-optimal front is below the Pareto front. Default is “minimize.”

  • how (str) –

    Sets the method used to traverse the near-optimal region. Accepts [‘all’,’random’,’farthest’].

    • ’all’ : Returns all near-optimal points.

    • ’random’ : Returns a random selection a set of n_points from the near-optimal region.

    • ’farthest’ : Returns n_points from the near-optimal space by doing a farthest-first-traversal in the design space.

  • seed (int) – Specifies the seed for a random number generator to ensure repeatable results. Default is 1234.

  • metric (str) – The string describing how the metric should be calculated. See the documentation for [scipy.spatial.distance.pdist](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html) for a complete list of values. Default is ‘euclidean.’

  • start_idx (int) – The index of the starting point. If None, a starting point will be chosen randomly. Default is None.

  • wide_form (boolean) – If True, the designs will be unpacked and each decision variable will have its own column in the resulting dataframe. Default is False.

Returns:

mga_df – Returns a dataframe with n_points rows and N_objectives + 1 columns, where the rows are data for each solution selected by the MGA algorithm and the columns are the performance values for that solution, with an additional designs column that holds the capacity portfolio.

Return type:

pandas.DataFrame

Warning

The following may result in an infinite-loop when using a farthest-first-traversal:

  • a matrix of rank 1 (i.e., all rows are identical / non-unique / non-independent)

If the average distance is unchanging, this means the algorithm found a point, or points, that is equidistant from every other point. The algorithm will stop when it reaches this point. In this case, it is recommended to use the all or the random options to generate alternative points. Or inspect their results.