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 ()
 
 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 2269 of file z3++.h.

Constructor & Destructor Documentation

◆ optimize()

optimize ( context c)
inline

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

2278 :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:362

◆ ~optimize()

~optimize ( )
inline

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

2279 { Z3_optimize_dec_ref(ctx(), m_opt); }
context & ctx() const
Definition: z3++.h:364
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 2281 of file z3++.h.

2281  {
2282  assert(e.is_bool());
2283  Z3_optimize_assert(ctx(), m_opt, e);
2284  }
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:364

◆ add() [2/3]

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

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

2285  {
2286  assert(e.is_bool());
2287  std::stringstream strm;
2288  strm << weight;
2289  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));
2290  }
context & ctx() const
Definition: z3++.h:364
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 2291 of file z3++.h.

2291  {
2292  assert(e.is_bool());
2293  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));
2294  }
context & ctx() const
Definition: z3++.h:364
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 2320 of file z3++.h.

2320 { 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:365
context & ctx() const
Definition: z3++.h:364
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 2307 of file z3++.h.

2307 { 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:365
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:364
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:106
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:130

◆ from_file()

void from_file ( char const *  filename)
inline

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

2324 { Z3_optimize_from_file(ctx(), m_opt, filename); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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 2325 of file z3++.h.

2325 { Z3_optimize_from_string(ctx(), m_opt, constraints); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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 2308 of file z3++.h.

2308 { 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:365
context & ctx() const
Definition: z3++.h:364
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 2326 of file z3++.h.

2326 { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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 2310 of file z3++.h.

2310  {
2311  Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());
2312  check_error();
2313  return expr(ctx(), r);
2314  }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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 2295 of file z3++.h.

2295  {
2296  return handle(Z3_optimize_maximize(ctx(), m_opt, e));
2297  }
context & ctx() const
Definition: z3++.h:364
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 2298 of file z3++.h.

2298  {
2299  return handle(Z3_optimize_minimize(ctx(), m_opt, e));
2300  }
context & ctx() const
Definition: z3++.h:364
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 2321 of file z3++.h.

2321 { 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:365
context & ctx() const
Definition: z3++.h:364
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:68

◆ operator Z3_optimize()

operator Z3_optimize ( ) const
inline

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

2280 { return m_opt; }

◆ pop()

void pop ( )
inline

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

2304  {
2305  Z3_optimize_pop(ctx(), m_opt);
2306  }
context & ctx() const
Definition: z3++.h:364
void Z3_API Z3_optimize_pop(Z3_context c, Z3_optimize d)
Backtrack one level.

◆ push()

void push ( )
inline

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

2301  {
2302  Z3_optimize_push(ctx(), m_opt);
2303  }
context & ctx() const
Definition: z3++.h:364
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 2309 of file z3++.h.

2309 { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }
Z3_error_code check_error() const
Definition: z3++.h:365
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:364

◆ statistics()

stats statistics ( ) const
inline

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

2322 { 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:365
context & ctx() const
Definition: z3++.h:364
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 2315 of file z3++.h.

2315  {
2316  Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());
2317  check_error();
2318  return expr(ctx(), r);
2319  }
Z3_error_code check_error() const
Definition: z3++.h:365
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:364

Friends And Related Function Documentation

◆ operator<<

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

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

2328 { 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.