Skip to content

How to add custom constraint #1118

@dezenn

Description

@dezenn

My optimization problem is the following:
I want to maximize the sum over binary variables. The only constraint I have is the following: I transform the ones in my binary array to corresponding indices, so e.g.
[1 0 0 1 0] -> [0 3]=indices
Then I use these indices to calculate a value of a matrix M[:, indices]. Now this value needs to be under a certain threshold.

I already have a good initial guess. Now if an additional zero gets flipped to a one during the optimization and the value is over the threshold it does not make any sense to further investigate this combination. So the one needs to be flipped back to the zero.

I have seen the custom lazy constraint handler about the traveling salesman problem but I still have troubles understanding the functionalities of the functions createCons, conscheck and consenfolp. I really do not know where to add my custom constraint function I use for calculating my matrix value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions