Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::ModelCopy Class Reference

#include <cp_model_presolve.h>

Public Member Functions

 ModelCopy (PresolveContext *context)
 
bool ImportAndSimplifyConstraints (const CpModelProto &in_model, bool first_copy=false, std::function< bool(int)> active_constraints=nullptr)
 
void ImportVariablesAndMaybeIgnoreNames (const CpModelProto &in_model)
 
void CreateVariablesFromDomains (const std::vector< Domain > &domains)
 

Detailed Description

This helper class perform copy with simplification from a model and a partial assignment to another model. The purpose is to minimize the size of the copied model, as well as to reduce the pressure on the memory sub-system.

It is currently used by the LNS part, but could be used with any other scheme that generates partial assignments.

Definition at line 379 of file cp_model_presolve.h.

Constructor & Destructor Documentation

◆ ModelCopy()

operations_research::sat::ModelCopy::ModelCopy ( PresolveContext * context)
explicit

Definition at line 11778 of file cp_model_presolve.cc.

Member Function Documentation

◆ CreateVariablesFromDomains()

void operations_research::sat::ModelCopy::CreateVariablesFromDomains ( const std::vector< Domain > & domains)

Setup new variables from a vector of domains. Inactive variables will be fixed to their lower bound.

Definition at line 11795 of file cp_model_presolve.cc.

◆ ImportAndSimplifyConstraints()

bool operations_research::sat::ModelCopy::ImportAndSimplifyConstraints ( const CpModelProto & in_model,
bool first_copy = false,
std::function< bool(int)> active_constraints = nullptr )

Copies all constraints from in_model to working model of the context.

During the process, it will read variable domains from the context, and simplify constraints to minimize the size of the copied model. Thus it is important that the context->working_model already have the variables part copied.

It returns false iff the model is proven infeasible.

It does not clear the constraints part of the working model of the context.

Note(user): If first_copy is true, we will reorder the scheduling constraint so that they only use reference to previously defined intervals. This allow to be more efficient later in a few preprocessing steps.

Todo
(user): Merge with the phase 1 of the presolve code.
Todo
(user): It seems easy to forget to update this if any new constraint contains an interval or if we add a field to an existing constraint. Find a way to remind contributor to not forget this.

If first_copy is true, we reorder the scheduling constraint to be sure they refer to interval before them.

Todo
(user): if ignore_names is false, we should make sure the name are properly copied by all these functions. Or we should never copy name and have a separate if (!ignore_name) copy the name...
Todo
(user): find a better way than copy then clear_name()?

This should be empty if first_copy is false.

Definition at line 11806 of file cp_model_presolve.cc.

◆ ImportVariablesAndMaybeIgnoreNames()

void operations_research::sat::ModelCopy::ImportVariablesAndMaybeIgnoreNames ( const CpModelProto & in_model)

Copy variables from the in_model to the working model. It reads the 'ignore_names' parameters from the context, and keeps or deletes names accordingly.

Definition at line 11780 of file cp_model_presolve.cc.


The documentation for this class was generated from the following files: