ScalarConstraint

class desdeo_problem.problem.ScalarConstraint(name, n_decision_vars, n_objective_funs, evaluator)[source]

Bases: ConstraintBase

A simple scalar constraint that evaluates to a single scalar.

Parameters:
  • name (str) – Name of the constraint.

  • n_decision_vars (int) – Number of decision variables present in the constraint.

  • n_objective_funs (int) – Number of objective functions present in the constraint.

  • evaluator (Callable) – A callable to evaluate the constraint.

__name

Name of the constraint.

Type:

str

__n_decision_vars

Number of decision variables present in the constraint.

Type:

int

__n_objective_funs

Number of objective functions present in the constraint.

Type:

int

__evaluator

A callable to evaluate the constraint.

Type:

Callable

Attributes Summary

evaluator

constraint evaluator callable

n_decision_vars

number of decision variables

n_objective_funs

number of objective functions

name

name

Methods Summary

evaluate(decision_vector, objective_vector)

Evaluate the constraint.

Attributes Documentation

evaluator

constraint evaluator callable

Returns:

A callable to evaluate the constraint.

Return type:

Callable

Type:

Property

n_decision_vars

number of decision variables

Returns:

Number of decision variables

Return type:

int

Type:

Property

n_objective_funs

number of objective functions

Returns:

Number of objective functions

Return type:

int

Type:

Property

name

name

Returns:

Name of the constraint

Return type:

str

Type:

Property

Methods Documentation

evaluate(decision_vector, objective_vector)[source]

Evaluate the constraint.

This evaluates the constraint and return a float indicating how and if the constraint was violated. A negative value indicates a violation and a positive value indicates a non-violation.

Parameters:
  • decision_vector (np.ndarray) – A decision_vector containing the values of the decision variables.

  • objective_vector (np.ndarray) – A decision_vector containing the values of the objective functions.

Returns:

A float indicating how the constraint holds.

Return type:

float

Raises:

ConstraintError – When something goes wrong evaluating the constraint or the objectives and decision vectors are of wrong shape.