Z3
Data Structures | Public Member Functions | Friends
optimize Class Reference
+ Inheritance diagram for optimize:

Data Structures

class  handle
 

Public Member Functions

 optimize (context &c)
 
 optimize (optimize &o)
 
optimizeoperator= (optimize const &o)
 
 ~optimize ()
 
 operator Z3_optimize () const
 
void add (expr const &e)
 
handle add (expr const &e, unsigned weight)
 
handle add (expr const &e, char const *weight)
 
handle maximize (expr const &e)
 
handle minimize (expr const &e)
 
void push ()
 
void pop ()
 
check_result check ()
 
model get_model () const
 
void set (params const &p)
 
expr lower (handle const &h)
 
expr upper (handle const &h)
 
expr_vector assertions () const
 
expr_vector objectives () const
 
stats statistics () const
 
void from_file (char const *filename)
 
void from_string (char const *constraints)
 
std::string help () const
 
- Public Member Functions inherited from object
 object (context &c)
 
 object (object const &s)
 
contextctx () const
 
Z3_error_code check_error () const
 

Friends

std::ostream & operator<< (std::ostream &out, optimize const &s)
 

Additional Inherited Members

- Protected Attributes inherited from object
contextm_ctx
 

Detailed Description

Definition at line 2293 of file z3++.h.

Constructor & Destructor Documentation

◆ optimize() [1/2]

optimize ( context c)
inline

Definition at line 2303 of file z3++.h.

2303 :object(c) { m_opt = Z3_mk_optimize(c); Z3_optimize_inc_ref(c, m_opt); }
Z3_optimize Z3_API Z3_mk_optimize(Z3_context c)
Create a new optimize context.
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize d)
Increment the reference counter of the given optimize context.
object(context &c)
Definition: z3++.h:371

◆ optimize() [2/2]

optimize ( optimize o)
inline

Definition at line 2304 of file z3++.h.

2304  :object(o) {
2305  Z3_optimize_inc_ref(o.ctx(), o.m_opt);
2306  m_opt = o.m_opt;
2307  }
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize d)
Increment the reference counter of the given optimize context.
object(context &c)
Definition: z3++.h:371

◆ ~optimize()

~optimize ( )
inline

Definition at line 2315 of file z3++.h.

2315 { Z3_optimize_dec_ref(ctx(), m_opt); }
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_dec_ref(Z3_context c, Z3_optimize d)
Decrement the reference counter of the given optimize context.

Member Function Documentation

◆ add() [1/3]

void add ( expr const &  e)
inline

Definition at line 2317 of file z3++.h.

2317  {
2318  assert(e.is_bool());
2319  Z3_optimize_assert(ctx(), m_opt, e);
2320  }
void Z3_API Z3_optimize_assert(Z3_context c, Z3_optimize o, Z3_ast a)
Assert hard constraint to the optimization context.
context & ctx() const
Definition: z3++.h:373

◆ add() [2/3]

handle add ( expr const &  e,
unsigned  weight 
)
inline

Definition at line 2321 of file z3++.h.

2321  {
2322  assert(e.is_bool());
2323  std::stringstream strm;
2324  strm << weight;
2325  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));
2326  }
context & ctx() const
Definition: z3++.h:373
unsigned Z3_API Z3_optimize_assert_soft(Z3_context c, Z3_optimize o, Z3_ast a, Z3_string weight, Z3_symbol id)
Assert soft constraint to the optimization context.

◆ add() [3/3]

handle add ( expr const &  e,
char const *  weight 
)
inline

Definition at line 2327 of file z3++.h.

2327  {
2328  assert(e.is_bool());
2329  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));
2330  }
context & ctx() const
Definition: z3++.h:373
unsigned Z3_API Z3_optimize_assert_soft(Z3_context c, Z3_optimize o, Z3_ast a, Z3_string weight, Z3_symbol id)
Assert soft constraint to the optimization context.

◆ assertions()

expr_vector assertions ( ) const
inline

Definition at line 2356 of file z3++.h.

2356 { Z3_ast_vector r = Z3_optimize_get_assertions(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
Z3_ast_vector Z3_API Z3_optimize_get_assertions(Z3_context c, Z3_optimize o)
Return the set of asserted formulas on the optimization context.
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:68

◆ check()

check_result check ( )
inline

Definition at line 2343 of file z3++.h.

2343 { Z3_lbool r = Z3_optimize_check(ctx(), m_opt); check_error(); return to_check_result(r); }
Z3_error_code check_error() const
Definition: z3++.h:374
Z3_lbool Z3_API Z3_optimize_check(Z3_context c, Z3_optimize o)
Check consistency and produce optimal values.
context & ctx() const
Definition: z3++.h:373
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:98
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:130

◆ from_file()

void from_file ( char const *  filename)
inline

Definition at line 2360 of file z3++.h.

2360 { Z3_optimize_from_file(ctx(), m_opt, filename); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_from_file(Z3_context c, Z3_optimize o, Z3_string s)
Parse an SMT-LIB2 file with assertions, soft constraints and optimization objectives. Add the parsed constraints and objectives to the optimization context.

◆ from_string()

void from_string ( char const *  constraints)
inline

Definition at line 2361 of file z3++.h.

2361 { Z3_optimize_from_string(ctx(), m_opt, constraints); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_from_string(Z3_context c, Z3_optimize o, Z3_string s)
Parse an SMT-LIB2 string with assertions, soft constraints and optimization objectives. Add the parsed constraints and objectives to the optimization context.

◆ get_model()

model get_model ( ) const
inline

Definition at line 2344 of file z3++.h.

2344 { Z3_model m = Z3_optimize_get_model(ctx(), m_opt); check_error(); return model(ctx(), m); }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
Z3_model Z3_API Z3_optimize_get_model(Z3_context c, Z3_optimize o)
Retrieve the model for the last Z3_optimize_check.

◆ help()

std::string help ( ) const
inline

Definition at line 2362 of file z3++.h.

2362 { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
Z3_string Z3_API Z3_optimize_get_help(Z3_context c, Z3_optimize t)
Return a string containing a description of parameters accepted by optimize.

◆ lower()

expr lower ( handle const &  h)
inline

Definition at line 2346 of file z3++.h.

2346  {
2347  Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());
2348  check_error();
2349  return expr(ctx(), r);
2350  }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
Z3_ast Z3_API Z3_optimize_get_lower(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve lower bound value or approximation for the i&#39;th optimization objective.

◆ maximize()

handle maximize ( expr const &  e)
inline

Definition at line 2331 of file z3++.h.

2331  {
2332  return handle(Z3_optimize_maximize(ctx(), m_opt, e));
2333  }
context & ctx() const
Definition: z3++.h:373
unsigned Z3_API Z3_optimize_maximize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a maximization constraint.

◆ minimize()

handle minimize ( expr const &  e)
inline

Definition at line 2334 of file z3++.h.

2334  {
2335  return handle(Z3_optimize_minimize(ctx(), m_opt, e));
2336  }
context & ctx() const
Definition: z3++.h:373
unsigned Z3_API Z3_optimize_minimize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a minimization constraint.

◆ objectives()

expr_vector objectives ( ) const
inline

Definition at line 2357 of file z3++.h.

2357 { Z3_ast_vector r = Z3_optimize_get_objectives(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
Z3_ast_vector Z3_API Z3_optimize_get_objectives(Z3_context c, Z3_optimize o)
Return objectives on the optimization context. If the objective function is a max-sat objective it is...
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:68

◆ operator Z3_optimize()

operator Z3_optimize ( ) const
inline

Definition at line 2316 of file z3++.h.

2316 { return m_opt; }

◆ operator=()

optimize& operator= ( optimize const &  o)
inline

Definition at line 2308 of file z3++.h.

2308  {
2309  Z3_optimize_inc_ref(o.ctx(), o.m_opt);
2310  Z3_optimize_dec_ref(ctx(), m_opt);
2311  m_opt = o.m_opt;
2312  m_ctx = o.m_ctx;
2313  return *this;
2314  }
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize d)
Increment the reference counter of the given optimize context.
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_dec_ref(Z3_context c, Z3_optimize d)
Decrement the reference counter of the given optimize context.
context * m_ctx
Definition: z3++.h:369

◆ pop()

void pop ( )
inline

Definition at line 2340 of file z3++.h.

2340  {
2341  Z3_optimize_pop(ctx(), m_opt);
2342  }
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_pop(Z3_context c, Z3_optimize d)
Backtrack one level.

◆ push()

void push ( )
inline

Definition at line 2337 of file z3++.h.

2337  {
2338  Z3_optimize_push(ctx(), m_opt);
2339  }
context & ctx() const
Definition: z3++.h:373
void Z3_API Z3_optimize_push(Z3_context c, Z3_optimize d)
Create a backtracking point.

◆ set()

void set ( params const &  p)
inline

Definition at line 2345 of file z3++.h.

2345 { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:374
void Z3_API Z3_optimize_set_params(Z3_context c, Z3_optimize o, Z3_params p)
Set parameters on optimization context.
context & ctx() const
Definition: z3++.h:373

◆ statistics()

stats statistics ( ) const
inline

Definition at line 2358 of file z3++.h.

2358 { Z3_stats r = Z3_optimize_get_statistics(ctx(), m_opt); check_error(); return stats(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:374
context & ctx() const
Definition: z3++.h:373
Z3_stats Z3_API Z3_optimize_get_statistics(Z3_context c, Z3_optimize d)
Retrieve statistics information from the last call to Z3_optimize_check.

◆ upper()

expr upper ( handle const &  h)
inline

Definition at line 2351 of file z3++.h.

2351  {
2352  Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());
2353  check_error();
2354  return expr(ctx(), r);
2355  }
Z3_error_code check_error() const
Definition: z3++.h:374
Z3_ast Z3_API Z3_optimize_get_upper(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve upper bound value or approximation for the i&#39;th optimization objective.
context & ctx() const
Definition: z3++.h:373

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
optimize const &  s 
)
friend

Definition at line 2364 of file z3++.h.

2364 { out << Z3_optimize_to_string(s.ctx(), s.m_opt); return out; }
Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o)
Print the current context as a string.