Skip to content

Multiple constraints minimization #18

Open
@dudifrid

Description

@dudifrid

First of all - thank you for the great repo!

Now, I have a question: is there any support in multiple constraints minimization? It is often the case, since I am minimizing a function that gets tensor as input, so I need multiple constraints for the relations between the input tensor's elements.

So far I've tried: list of dictionaries, dictionary of lists, dictionary that returns tensor with > 1 elements, and dictionary that returns list of tensors. They all failed.

Here's my toy snippet of code with one constraint:

from torchmin import minimize_constr
import torch
import torch.nn as nn

eps0 = torch.rand((2,3))

res = minimize_constr(
    lambda x : nn.L1Loss()(x.sum(),  x.sum()),
    eps0, 
    max_iter=100,
    constr=dict(
        fun=lambda x: x.square().sum(), 
        lb=1, ub=1
    ),
    disp=1
)

eps = res.x

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions