Skip to content

Commit

Permalink
Minor modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Mar 4, 2019
1 parent bce29cf commit f0b9dd5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ pymop - Multi-Objective Optimization Problems
This framework provides a collection of test problems in Python. The main features are:

- Most important multi-objective test function is one place
- Vectorized evaluation by using numpy matrices
- Vectorized evaluation by using numpy matrices (no for loops)
- Gradients and Hessian matrices are available through automatic differentiation
- Easily new problems can be created using custom classes or functions


Here, you can find a detailed documentation and information about the framework:
https://www.egr.msu.edu/coinlab/blankjul/pymop/

Expand Down
9 changes: 6 additions & 3 deletions pymop/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,16 @@ def calc_gradient(X):

# if constraint violation should be returned as well
if self.n_constr == 0:
out["CV"] = np.zeros([X.shape[0], 1])
CV = np.zeros([X.shape[0], 1])
else:
out["CV"] = Problem.calc_constraint_violation(out["G"])
CV = Problem.calc_constraint_violation(out["G"])

if "CV" in return_values_of:
out["CV"] = CV

# if an additional boolean flag for feasibility should be returned
if "feasible" in return_values_of:
out["feasible"] = (out["CV"] <= 0)
out["feasible"] = (CV <= 0)

# remove the first dimension of the output - in case input was a 1d- vector
if only_single_value:
Expand Down
17 changes: 10 additions & 7 deletions pymop/usage/evaluate_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

problem = ZDT1(n_var=10)

# evaluation function returns by default two numpy arrays - objective function values and constraints -
# as input either provide a vector
F, G = problem.evaluate(np.random.random(10))
# if the function does not have any constraints only function values are returned
F = problem.evaluate(np.random.random(10))

# or a whole matrix to evaluate several solutions at once
F, G = problem.evaluate(np.random.random((100, 10)))
# in case more than one solution should be evaluated you can provide a matrix
F = problem.evaluate(np.random.random((100, 10)))

from pymop.problems.welded_beam import WeldedBeam
problem = WeldedBeam()

# if no constraints should be returned
# by default a problem with constrained will also return the constraint violation
F, CV = problem.evaluate(np.random.random((100, 4)))

# if only specific values are required return_values_of can be defined
F = problem.evaluate(np.random.random((100, 4)), return_values_of=["F"])

F, G, CV = problem.evaluate(np.random.random((100, 4)), return_values_of=["F", "G", "CV"])
# in this case more values are returned (also the gradient of the objective values!)
F, G, CV, dF = problem.evaluate(np.random.random((100, 4)), return_values_of=["F", "G", "CV", "dF"])
22 changes: 0 additions & 22 deletions pymop/usage/return_specific_values_of_function.py

This file was deleted.

0 comments on commit f0b9dd5

Please sign in to comment.