Class: Gecode::IntEnum::Sort::SortConstraintWithOptions

Inherits:
Constraint
  • Object
show all
Defined in:
lib/gecoder/interface/constraints/int_enum/sort.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Constraint

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraint

Instance Method Details

#postObject

:nodoc:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/gecoder/interface/constraints/int_enum/sort.rb', line 81

def post
  if @params[:target].nil?
    # We must have a target.
    lhs = @params[:lhs].to_int_enum
    @params[:target] = @model.int_var_array(lhs.size, lhs.domain_range)
  end
  
  # Prepare the parameters.
  params = @params.values_at(:lhs, :target, :order).map do |param| 
    if param.respond_to? :to_int_enum
      param.to_int_enum.bind_array
    else
      param
    end
  end.delete_if{ |param| param.nil? }
  params.concat propagation_options
  
  # Post the constraint.
  Gecode::Raw::sorted(@model.active_space, *params)
end