Generate the user specified constraints
978390
def _generate_actual_grp_constraints(network_constraints):
    
    if 'constraints' not in network_constraints:
        return []

    constraints = network_constraints['constraints']
    actual = []
    for desc in constraints:
        descs = _expand_description(desc)
        for desc in descs:
            actual.append(desc)
            if 'symetric' in desc:
                sym = desc.copy()
                sym['src'] = desc['dst']
                sym['dst'] = desc['src']
                actual.append(sym)
    return actual
682755
def __set_hard_hard_constraints(self, tdata1, tdata2, seeds):
        
        seeds_mask = (seeds == 1) | (seeds == 3)
        tdata2[seeds_mask] = np.max(tdata2) + 1
        tdata1[seeds_mask] = 0

        seeds_mask = (seeds == 2) | (seeds == 4)
        tdata1[seeds_mask] = np.max(tdata1) + 1
        tdata2[seeds_mask] = 0

        return tdata1, tdata2
289774
def hidden_constraints(self):
        
        try:
            return self._hidden_constraints
        except AttributeError:
            self._hidden_constraints = ConstraintDict()
            return self._hidden_constraints
1029936
def in_constraints(self):
        
        expressions = []
        for uniqueid in self._in_constraints:
            expressions.append(self._bundle.get_parameter(context='constraint', uniqueid=uniqueid))
        return expressions
692060
def indicator_constraints(self,x):
        
        x = np.atleast_2d(x)
        I_x = np.ones((x.shape[0],1))
        if self.constraints is not None:
            for d in self.constraints:
                try:
                    exec('constraint = lambda x:' + d['constraint'], globals())
                    ind_x = (constraint(x) <= 0) * 1
                    I_x *= ind_x.reshape(x.shape[0],1)
                except:
                    print('Fail to compile the constraint: ' + str(d))
                    raise
        return I_x
997406
private void generateQvarConstraints() {
        final StringBuilder qvarConstrBuilder = new StringBuilder();
        final StringBuilder qvarMapStrBuilder = new StringBuilder();
        final Iterator<Map.Entry<String, ArrayList<String>>> entryIterator = qvar.entrySet().iterator();
        if (entryIterator.hasNext()) {
            qvarMapStrBuilder.append("declare function local:qvarMap($x) {\n map {");

            while (entryIterator.hasNext()) {
                final Map.Entry<String, ArrayList<String>> currentEntry = entryIterator.next();

                final Iterator<String> valueIterator = currentEntry.getValue().iterator();
                final String firstValue = valueIterator.next();

                qvarMapStrBuilder.append('"').append(currentEntry.getKey()).append('"')
                        .append(" : (data($x").append(firstValue).append("/@xml:id)");

                //check if there are additional values that we need to constrain
                if (valueIterator.hasNext()) {
                    if (qvarConstrBuilder.length() > 0) {
                        //only add beginning and if it's an additional constraint in the aggregate qvar string
                        qvarConstrBuilder.append("\n and ");
                    }
                    while (valueIterator.hasNext()) {
                        //process second value onwards
                        final String currentValue = valueIterator.next();
                        qvarMapStrBuilder.append(",data($x").append(currentValue).append("/@xml-id)");
                        //These constraints specify that the same qvars must refer to the same nodes,
                        //using the XQuery "=" equality
                        //This is equality based on: same text, same node names, and same children nodes
                        qvarConstrBuilder.append("$x").append(firstValue).append(" = $x").append(currentValue);
                        if (valueIterator.hasNext()) {
                            qvarConstrBuilder.append(" and ");
                        }
                    }
                }
                qvarMapStrBuilder.append(')');
                if (entryIterator.hasNext()) {
                    qvarMapStrBuilder.append(',');
                }
            }
            qvarMapStrBuilder.append("}\n};");
        }
        qvarMapVariable = qvarMapStrBuilder.toString();
        qvarConstraint = qvarConstrBuilder.toString();
    }
1251150
@VisibleForTesting
  URIBuilder constraints(Constraints constraints) {
    options.putAll(constraints.toQueryMap());
    this.isView = !constraints.isUnbounded();
    return this;
  }
142364
def __eliminate_unused_constraits (self, objects):
        
        result = []
        for c in self.constraints_:
            if c [0] in objects and c [1] in objects:
                result.append (c)

        return result
363826
function () {
			var args = slice.call(arguments),
				constraint = options.args_map.getOrPut(args, function() {
					return new Constraint(function () {
						return getter_fn.apply(options.context, args);
					});
				});
			return constraint.get();
		}
737727
def set_constraint_bound(self, name, value):
        """"""
        index = self._get_constraint_index(name)
        self.upper_bounds[index] = value
        self._reset_solution()
629352
def no_constraints(cls, callback):
        
        cls._constraints = False

        results = callback()

        cls._constraints = True

        return results
1161760
def constrain_opts(self, constraint_dict, options):
        
        constraints = {}
        for constraint in constraint_dict:
            if constraint != 'self':
                if (constraint_dict[constraint] or
                        constraint_dict[constraint] == ''):
                    constraints[constraint] = constraint_dict[constraint]
        results = self.constrained_sections(constraints=constraints,
                                            options=options)
        return results, self.template
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
324693
def initial_solve_constraints
      @identifier.initial_dependencies.flat_map do |dependency|
        dependency.constraints.map do |constraint|
          [dependency.name, constraint]
        end
      end
    end
384760
def _build_action_bound_constraints_table(self):
        ''''''
        self.action_lower_bound_constraints = {}
        self.action_upper_bound_constraints = {}

        for name, preconds in self.local_action_preconditions.items():

            for precond in preconds:
                expr_type = precond.etype
                expr_args = precond.args

                bounds_expr = None

                if expr_type == ('aggregation', 'forall'):
                    inner_expr = expr_args[1]
                    if inner_expr.etype[0] == 'relational':
                        bounds_expr = inner_expr
                elif expr_type[0] == 'relational':
                    bounds_expr = precond

                if bounds_expr:
                    # lower bound
                    bound = self._extract_lower_bound(name, bounds_expr)
                    if bound is not None:
                        self.action_lower_bound_constraints[name] = bound
                    else: # upper bound
                        bound = self._extract_upper_bound(name, bounds_expr)
                        if bound is not None:
                            self.action_upper_bound_constraints[name] = bound
1126419
def cursor_constrain (self):
        '''
        '''

        self.cur_r = constrain (self.cur_r, 1, self.rows)
        self.cur_c = constrain (self.cur_c, 1, self.cols)
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