mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
add theory outlline
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2b968f9e63
commit
0d8de8f65f
5 changed files with 280 additions and 22 deletions
|
@ -55,6 +55,7 @@ z3_add_component(smt
|
|||
theory_dl.cpp
|
||||
theory_dummy.cpp
|
||||
theory_fpa.cpp
|
||||
theory_jobscheduler.cpp
|
||||
theory_lra.cpp
|
||||
theory_opt.cpp
|
||||
theory_pb.cpp
|
||||
|
|
146
src/smt/theory_jobscheduler.cpp
Normal file
146
src/smt/theory_jobscheduler.cpp
Normal file
|
@ -0,0 +1,146 @@
|
|||
/*++
|
||||
Copyright (c) 2018 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
theory_jobscheduler.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2018-09-08.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include "smt/theory_jobscheduler.h"
|
||||
#include "smt/smt_context.h"
|
||||
|
||||
namespace smt {
|
||||
|
||||
theory_var theory_jobscheduler::mk_var(enode * n) {
|
||||
theory_var v = theory::mk_var(n);
|
||||
return v;
|
||||
}
|
||||
|
||||
bool theory_jobscheduler::internalize_atom(app * atom, bool gate_ctx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool theory_jobscheduler::internalize_term(app * term) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void theory_jobscheduler::assign_eh(bool_var v, bool is_true) {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::new_eq_eh(theory_var v1, theory_var v2) {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::new_diseq_eh(theory_var v1, theory_var v2) {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::push_scope_eh() {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::pop_scope_eh(unsigned num_scopes) {
|
||||
|
||||
}
|
||||
|
||||
final_check_status theory_jobscheduler::final_check_eh() {
|
||||
return FC_DONE;
|
||||
}
|
||||
|
||||
bool theory_jobscheduler::can_propagate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void theory_jobscheduler::propagate() {
|
||||
|
||||
}
|
||||
|
||||
theory_jobscheduler::theory_jobscheduler(ast_manager& m): theory(m.get_family_id("jobshop")), m(m), u(m) {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::display(std::ostream & out) const {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::collect_statistics(::statistics & st) const {
|
||||
|
||||
}
|
||||
|
||||
void theory_jobscheduler::init_model(model_generator & m) {
|
||||
|
||||
}
|
||||
|
||||
model_value_proc * theory_jobscheduler::mk_value(enode * n, model_generator & mg) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool theory_jobscheduler::get_value(enode * n, expr_ref & r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
theory * theory_jobscheduler::mk_fresh(context * new_ctx) {
|
||||
return alloc(theory_jobscheduler, new_ctx->get_manager());
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::est(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::lst(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::ect(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::lct(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::start(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t theory_jobscheduler::end(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned theory_jobscheduler::resource(unsigned j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void theory_jobscheduler::add_job_resource(unsigned j, unsigned r, unsigned cap, unsigned loadpct, uint64_t end) {
|
||||
m_jobs.reserve(j + 1);
|
||||
m_resources.reserve(r + 1);
|
||||
job_info& ji = m_jobs[j];
|
||||
if (ji.m_resource2index.contains(r)) {
|
||||
throw default_exception("resource already bound to job");
|
||||
}
|
||||
ji.m_resource2index.insert(r, ji.m_resources.size());
|
||||
ji.m_resources.push_back(job_resource(r, cap, loadpct, end));
|
||||
SASSERT(!m_resources[r].m_jobs.contains(j));
|
||||
m_resources[r].m_jobs.push_back(j);
|
||||
}
|
||||
|
||||
void theory_jobscheduler::add_resource_available(unsigned r, unsigned max_loadpct, uint64_t start, uint64_t end) {
|
||||
SASSERT(start < end);
|
||||
m_resources.reserve(r + 1);
|
||||
m_resources[r].m_available.push_back(res_available(max_loadpct, start, end));
|
||||
}
|
||||
|
||||
};
|
||||
|
124
src/smt/theory_jobscheduler.h
Normal file
124
src/smt/theory_jobscheduler.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*++
|
||||
Copyright (c) 2018 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
theory_jobscheduling.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Propagation solver for jobscheduling problems.
|
||||
It relies on an external module to tighten bounds of
|
||||
job variables.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2018-09-08.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#pragma once;
|
||||
|
||||
#include "smt/smt_theory.h"
|
||||
#include "ast/jobshop_decl_plugin.h"
|
||||
|
||||
namespace smt {
|
||||
|
||||
class theory_jobscheduler : public theory {
|
||||
|
||||
struct job_resource {
|
||||
unsigned m_resource_id; // id of resource
|
||||
unsigned m_capacity; // amount of resource to use
|
||||
unsigned m_loadpct; // assuming loadpct
|
||||
uint64_t m_end; // must run before
|
||||
job_resource(unsigned r, unsigned cap, unsigned loadpct, uint64_t end):
|
||||
m_resource_id(r), m_capacity(cap), m_loadpct(loadpct), m_end(end) {}
|
||||
};
|
||||
|
||||
struct job_info {
|
||||
vector<job_resource> m_resources; // resources allowed to run job.
|
||||
u_map<unsigned> m_resource2index; // resource to index into vector
|
||||
};
|
||||
|
||||
struct res_available {
|
||||
unsigned m_loadpct;
|
||||
uint64_t m_start;
|
||||
uint64_t m_end;
|
||||
res_available(unsigned load_pct, uint64_t start, uint64_t end):
|
||||
m_loadpct(load_pct),
|
||||
m_start(start),
|
||||
m_end(end)
|
||||
{}
|
||||
};
|
||||
|
||||
struct res_info {
|
||||
unsigned_vector m_jobs; // jobs allocated to run on resource
|
||||
vector<res_available> m_available; // time intervals where resource is available
|
||||
uint64_t m_end; // can't run after
|
||||
res_info(): m_end(std::numeric_limits<uint64_t>::max()) {}
|
||||
};
|
||||
|
||||
ast_manager& m;
|
||||
jobshop_util u;
|
||||
vector<job_info> m_jobs;
|
||||
vector<res_info> m_resources;
|
||||
|
||||
protected:
|
||||
|
||||
theory_var mk_var(enode * n) override;
|
||||
|
||||
bool internalize_atom(app * atom, bool gate_ctx) override;
|
||||
|
||||
bool internalize_term(app * term) override;
|
||||
|
||||
void assign_eh(bool_var v, bool is_true) override;
|
||||
|
||||
void new_eq_eh(theory_var v1, theory_var v2) override;
|
||||
|
||||
void new_diseq_eh(theory_var v1, theory_var v2) override;
|
||||
|
||||
void push_scope_eh() override;
|
||||
|
||||
void pop_scope_eh(unsigned num_scopes) override;
|
||||
|
||||
final_check_status final_check_eh() override;
|
||||
|
||||
bool can_propagate() override;
|
||||
|
||||
void propagate() override;
|
||||
|
||||
public:
|
||||
|
||||
theory_jobscheduler(ast_manager& m);
|
||||
|
||||
~theory_jobscheduler() override {}
|
||||
|
||||
void display(std::ostream & out) const override;
|
||||
|
||||
void collect_statistics(::statistics & st) const override;
|
||||
|
||||
void init_model(model_generator & m) override;
|
||||
|
||||
model_value_proc * mk_value(enode * n, model_generator & mg) override;
|
||||
|
||||
bool get_value(enode * n, expr_ref & r) override;
|
||||
|
||||
theory * mk_fresh(context * new_ctx) override; // { return alloc(theory_jobscheduler, new_ctx->get_manager()); }
|
||||
|
||||
public:
|
||||
// assignments:
|
||||
uint64_t est(unsigned j); // earliest start time of job j
|
||||
uint64_t lst(unsigned j); // last start time
|
||||
uint64_t ect(unsigned j); // earliest completion time
|
||||
uint64_t lct(unsigned j); // last completion time
|
||||
uint64_t start(unsigned j); // start time of job j
|
||||
uint64_t end(unsigned j); // end time of job j
|
||||
unsigned resource(unsigned j); // resource of job j
|
||||
|
||||
// set up model
|
||||
void add_job_resource(unsigned j, unsigned r, unsigned cap, unsigned loadpct, uint64_t end);
|
||||
void add_resource_available(unsigned r, unsigned max_loadpct, uint64_t start, uint64_t end);
|
||||
};
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue