Add multiple constraints at once
14233
def add_constraints(constrs)
      GLPK.glp_add_rows(@ptr, constrs.length)

      # Store each constraint and initialize a matrix used to hold
      # the coefficients of each value in the constraint matrix
      #
      # * ia - row (constraint) index
      # * ja - column (variable) index
      # * ar - constraint coefficient
      constrs.each do |constr|
        store_constraint constr
        constr.expression.terms.each do |var, coeff|
          @ia << constr.index
          @ja << var.index
          @ar << coeff
        end
      end

      ia_buffer = build_pointer_array @ia, :int
      ja_buffer = build_pointer_array @ja, :int
      ar_buffer = build_pointer_array @ar, :double

      GLPK.glp_load_matrix(@ptr, @ar.length - 1, ia_buffer, ja_buffer,
                           ar_buffer)

      @constraints.concat constrs
    end
577293
def _get_constraints(self):
        """"""
        num_edges = len(self.edges)
        for k in range(num_edges):
            for i in range(num_edges):
                # add to constraints if i shared an edge with k
                if k != i and self.edges[k].is_adjacent(self.edges[i]):
                    self.edges[k].neighbors.append(i)
893796
def add(self, *constraints: Tuple[Bool]) -> None:
        
        raw_constraints = [
            c.raw for c in cast(Tuple[Bool], constraints)
        ]  # type: List[z3.BoolRef]
        self.constraints.extend(raw_constraints)
78379
def add(self, *constraints):
        
        cc = self._adjust_constraint_list(constraints)
        return self._solver.add(cc)
389676
def add_constraints(self):
        
        if self._constraints:
            super(MorphOneOrMany, self).add_constraints()

            self._query.where(self._morph_type, self._morph_name)
570761
public function setConstraints($constraints)
    {
        foreach ($constraints as $fieldName => $v) {
            if (is_array($v)) {
                foreach ($v as $constraintFromArray) {
                    $this->setConstraint($fieldName, $constraintFromArray);
                }
            } else {
                $this->setConstraint($fieldName, $v);
            }
        }

        return $this;
    }
1328552
public function addConstraints()
    {
        $localValue = $this->farParent[$this->localKey];

        $this->performJoin();

        if (static::$constraints) {
            $this->query->where($this->getQualifiedFirstKeyName(), '=', $localValue);
        }
    }
256744
public void addBetaConstraint(BetaNodeFieldConstraint constraint) {
        if ( constraint != null ) {
            BetaNodeFieldConstraint[] tmp = this.betaConstraints;
            this.betaConstraints = new BetaNodeFieldConstraint[tmp.length + 1];
            System.arraycopy( tmp,
                              0,
                              this.betaConstraints,
                              0,
                              tmp.length );
            this.betaConstraints[this.betaConstraints.length - 1] = constraint;
            this.updateRequiredDeclarations( constraint );
            this.setType( Constraint.ConstraintType.BETA );
        }
    }
1124594
def add_constraint(self, op, val):
        
        if len(self.constraints) > 0:
            if op.is_equality():
                clist = ', '.join(map(str, self.constraints))
                raise ValueError('Field {}: equality operator cannot be combined '
                                 'with others: {}'.format(self._field.name, clist))
            elif op.is_exists():
                raise ValueError('Field {}: existence is implied '
                                 'by other operators'.format(self._field.name))
        constraint = Constraint(self._field, op, val)
        self.constraints.append(constraint)
        if self._field.has_subfield():
            self._array = True
        elif op.is_inequality():
            self._range = True
303735
public Mapper<K, V> constraint(Restraint<K, V> constraint) {
		return addConstraint(constraint);
	}
1302402
function () {
		var bones = this.bones;
		for (var i = 0, n = bones.length; i < n; i++)
			bones[i].setToSetupPose();

		var ikConstraints = this.ikConstraints;
		for (var i = 0, n = ikConstraints.length; i < n; i++) {
			var constraint = ikConstraints[i];
			constraint.bendDirection = constraint.data.bendDirection;
			constraint.mix = constraint.data.mix;
		}

		var transformConstraints = this.transformConstraints;
		for (var i = 0, n = transformConstraints.length; i < n; i++) {
			var constraint = transformConstraints[i];
			constraint.translateMix = constraint.data.translateMix;
			constraint.x = constraint.data.x;
			constraint.y = constraint.data.y;
		}
	}
907149
def add_constraint(self, func, variables, default_values=None):
        
        self._constraints.append((func, variables, default_values or ()))
181864
public void addSparseConstraint(int component, int index, double value) {
    constraints.add(new Constraint(component, index, value));
  }
840580
def lift_constraints(cr, table, column):
    """"""
    cr.execute(
        'select relname, array_agg(conname) from '
        '(select t1.relname, c.conname '
        'from pg_constraint c '
        'join pg_attribute a '
        'on c.confrelid=a.attrelid and a.attnum=any(c.conkey) '
        'join pg_class t on t.oid=a.attrelid '
        'join pg_class t1 on t1.oid=c.conrelid '
        'where t.relname=%(table)s and attname=%(column)s '
        'union select t.relname, c.conname '
        'from pg_constraint c '
        'join pg_attribute a '
        'on c.conrelid=a.attrelid and a.attnum=any(c.conkey) '
        'join pg_class t on t.oid=a.attrelid '
        'where relname=%(table)s and attname=%(column)s) in_out '
        'group by relname',
        {
            'table': table,
            'column': column,
        })
    for table, constraints in cr.fetchall():
        cr.execute(
            'alter table %s drop constraint %s',
            (AsIs(table), AsIs(', drop constraint '.join(constraints)))
        )
1255210
def add_constraints(constrs)
      cbeg, cind, cval = build_constraint_matrix constrs

      cbeg_buffer = build_pointer_array cbeg, :int
      cind_buffer = build_pointer_array cind, :int
      cval_buffer = build_pointer_array cval, :double
      sense_buffer = build_pointer_array(constrs.map do |c|
        gurobi_sense(c.sense)
      end, :char)
      rhs_buffer = build_pointer_array constrs.map(&:rhs), :double

      names_buffer = build_pointer_array array_to_pointers_to_names(constrs),
                                         :pointer

      ret = Gurobi.GRBaddconstrs @ptr, constrs.length, cind.length,
                                 cbeg_buffer, cind_buffer, cval_buffer,
                                 sense_buffer, rhs_buffer, names_buffer
      fail if ret != 0

      constrs.each do |constr|
        constr.model = self
        constr.index = @constraints.length
        constr.freeze
        @constraints << constr
      end
    end
1047546
def add_constraints(constrs)
      start, index, value = build_constraint_matrix constrs
      start_buffer = build_pointer_array start, :int
      index_buffer = build_pointer_array index, :int
      value_buffer = build_pointer_array value, :double

      Cbc.Cbc_loadProblem @ptr, @variables.length, constrs.length,
                          start_buffer, index_buffer, value_buffer,
                          nil, nil, nil, nil, nil

      store_model constrs, @variables
    end
820903
public function addConstraints()
    {
        $parentTable = $this->parent->getTable();

        $this->setJoin();
        if (static::$constraints && !$this->throughKey) {
            $localValue = $this->farParent[$this->localKey];
            $this->query->where($parentTable.'.'.$this->firstKey, '=', $localValue);
        } else {
            $localValue = $this->farParent['id'];
            $this->query->where($this->firstKey . '.' . $this->farParentRelatedKey, '=', $localValue);
        }

    }