Skip to content

addConsLocal updated and SCIPdelConsNode added#485

Closed
CGraczyk wants to merge 6 commits intomasterfrom
addConsLocal
Closed

addConsLocal updated and SCIPdelConsNode added#485
CGraczyk wants to merge 6 commits intomasterfrom
addConsLocal

Conversation

@CGraczyk
Copy link
Collaborator

Based on pull request in #418
Changelog updated.
Should the parameter "stickingatnode" in the addConsLocal function be True or False?

There are now two separate createCons functons, old:

def createCons(self, Conshdlr conshdlr, name, initial=True, separate=True, enforce=True, check=True, propagate=True,
               local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False):
    """Create a constraint of a custom constraint handler

    :param Conshdlr conshdlr: constraint handler
    :param name: name of constraint
    :param initial:  (Default value = True)
    :param separate:  (Default value = True)
    :param enforce:  (Default value = True)
    :param check:  (Default value = True)
    :param propagate:  (Default value = True)
    :param local:  (Default value = False)
    :param modifiable:  (Default value = False)
    :param dynamic:  (Default value = False)
    :param removable:  (Default value = False)
    :param stickingatnode:  (Default value = False)

    """

    n = str_conversion(name)
    cdef SCIP_CONSHDLR* scip_conshdlr
    scip_conshdlr = SCIPfindConshdlr(self._scip, str_conversion(conshdlr.name))
    constraint = Constraint()
    PY_SCIP_CALL(SCIPcreateCons(self._scip, &(constraint.scip_cons), n, scip_conshdlr, <SCIP_CONSDATA*>constraint,
                            initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
    return constraint

and the new one added in #418 :

    def _createCons(self, cons, **kwargs):
            deg = cons.expr.degree()
            cdef Constraint py_cons

    if deg <= 1:
        py_cons = self._createLinCons(cons, **kwargs)
    elif deg <= 2:
        py_cons = self._createQuadCons(cons, **kwargs)
    elif deg == float('inf'): # general nonlinear
        return self._createGenNonlinearCons(cons, **kwargs)
    else:
        return self._createNonlinearCons(cons, **kwargs)
    return py_cons

Is there a reason to have this distinction?

CharJon and others added 2 commits March 18, 2021 08:49
* Prototype for addition of addExprConsNode to add ExprCons to Nodes.

* Extract _createLinCons

* Unify createCons and make addConsNode more compact.

* Fix segfault caused by addConsNode when called with ExprCons
@CGraczyk CGraczyk requested a review from mattmilten March 18, 2021 08:40
@CGraczyk CGraczyk closed this Mar 18, 2021
@CGraczyk CGraczyk deleted the addConsLocal branch March 18, 2021 15:13
@CGraczyk CGraczyk restored the addConsLocal branch August 8, 2022 13:35
@CGraczyk
Copy link
Collaborator Author

CGraczyk commented Aug 8, 2022

i restored the branch, but the issue here is that in the new SCIP version, the way nonlinear constraints are handled has changed dramatically, which is why that distinction is no longer valid as is i believe - but maybe we can make it work for the new version and merge it.
Since this would resolve #605 I think we should look into this.

@CGraczyk CGraczyk reopened this Aug 8, 2022
@mmghannam
Copy link
Member

This has currently a lot of conflicts with the master branch, I will close it for now until it's ready to be merged.

@mmghannam mmghannam closed this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants