Git Product home page Git Product logo

doe's People

Contributors

davidwalz avatar dlinzner-bcs avatar osburg avatar r-m-lee avatar rluce avatar valentingregoirebasf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

doe's Issues

NchooseK + mixture constraints fail

NchooseK constraint fails when in addition a mixture constraint (sum(x_i) = 1.0) is included. The warning Sampling of points fulfilling this problem's constraints is not implemented appears. The resulting design is a trivial collection of runs with a single input set to 1 with all the other to 0. In the example code below, the goal is to have a simple linear design for a four-ingredient mixture (x1+x2+x3+x4+x5=1) with a maximum of three ingredients:

num_inputs = 4
inputs = [f"x{i+1}" for i in range(num_inputs)]
print('Inputs\t   :', inputs)

# mixture constraint
constr1 = opti.LinearEquality(names=[x for x in inputs], lhs=[1 for _ in inputs], rhs=1)
print('Constraints:', constr1)
# n-choose-k
num_nCk_active = 2
constr2 = opti.NChooseK([x for x in inputs], max_active=num_nCk_active)

problem = opti.Problem(
    inputs=[opti.Continuous(x, domain=[0., 1.]) for x in inputs],
    outputs=[opti.Continuous("y")],
    constraints=[constr2, constr1],
)

doe = doe.find_local_max_ipopt(
        problem=problem,
        model_type="linear"
)

add D-optimality score

A nice-to-have method could return a D-optimality score, such as the log-determinant of the information matrix log(det(X^T X)). This would allow easy comparison between designs.

Think about merging this package into opti

DoE depends on opti and at this point essentially provides a single user-facing function.
I propose to merge doe into opti. Since ipopt is not a nicely pip-installable depency, this should be done as an optional submodule.

The advantage would be that generic functionality such as the relaxation problem context and the corner point sampling would profit opti as well, and we have less hassle developing a single package.

Enable user to provide jacobian for nonlinear constraints

If no jacobian is provided for a constraint, IPOPT will approximate it using finite differences. For linear constraints the jacobian is generated internally by doe during the processing of the provided opti.Problem. For arbitrary nonlinear constraints this cannot be done easily. However, in high dimensions finite the difference approximation is too time consuming.
Therefore, there should be an option for the user to provide a jacobian for nonlinear constraints.

To illustrate the problem: Here we have 10 variables with 1 nonlinear constraint and a linear model.

problem = opti.Problem(
    inputs=opti.Parameters([opti.Continuous(f"x{i+1}", [0, 1]) for i in range(10)]),
    outputs=[opti.Continuous("y")],
    constraints=[opti.NonlinearEquality("(x1**2 + x2**2 + x3**2 + x4**2 + x5**2 + x6**2 + x7**2 + x8**2 + x9**2)**0.5 - x10")],
)

result = find_local_max_ipopt(problem, "linear", ipopt_options={"disp":5, "maxiter": 100})
result.round(3)

And now the same with a linear constraint (mixture constraint)

problem = opti.Problem(
    inputs=opti.Parameters([opti.Continuous(f"x{i+1}", [0, 1]) for i in range(10)]),
    outputs=[opti.Continuous("y")],
    constraints=[opti.LinearEquality(names=[f"x{i+1}" for i in range(10)], rhs=1)],
)

result = find_local_max_ipopt(problem, "linear", ipopt_options={"disp":5, "maxiter": 100})
result.round(3)

When you run both examples you will see that even in case of a moderate problem size of 10 variables with only one nonlinear constraint we observe that the optimization slows down significantly (and maybe even get worse results due to inaccuracies of the finite difference approximation).

Design does not satisfy constraint

When a design does not satisfy a constraint it is returned as if everything went well, it would be nice to warn the user about this.
Example: a simple three-input linear design with a formulation constraint (x1+x2+x3=1). If all inputs have the domain [0.5,1], then the formulation constraint cannot be satisfied

import pandas as pd
import opti
import doe

inputs = ['x1', 'x2', 'x3']
# formulation constraint
constr1 = opti.LinearEquality(names=inputs, rhs=1)
problem = opti.Problem(
                      inputs=[opti.Continuous(x, domain=[0.5, 1]) for x in inputs],
                      outputs=[opti.Continuous("y")],
                      constraints=[constr1],
)
df = doe.find_local_max_ipopt(problem=problem,
                              model_type="linear")

constr1.satisfied(df).values
# array([False, False, False, False, False, False, False])

The last output shows that the formulation constraint is not satisfied; nonetheless, the (incorrect) design is generated and returned with no warnings to the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.