Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
533cb83
P >= 0 Constraints for LP and some linux include problems fixed
Sep 22, 2025
c01c8aa
fixed p>= constraints
Sep 29, 2025
bafd669
added lp and solution printing to potentially debug some cases
Oct 17, 2025
6235336
lp loop constraints
Nov 21, 2025
17d4552
changed tolerances and bound
Dec 4, 2025
a8befab
lower constant
Dec 18, 2025
7cfb5d4
lp changes mostly working?
Feb 28, 2026
5ed6931
fix nested operators creating incorrect lps
Mar 5, 2026
07ab9f0
fix unqunatified conditions
Mar 8, 2026
99308c0
improve unquantified condition handling
Mar 8, 2026
c7102bd
less conservative operator handling
Mar 16, 2026
72974d9
small changes
Mar 19, 2026
9da2d6f
timestamp added
Mar 19, 2026
880c09d
basic lp construction changes
May 17, 2026
a0297c9
new F rule formulation implemented
May 26, 2026
13bba69
to rerun actions
bruno-go May 27, 2026
0cc1ace
fix internal lp state not being reset
May 28, 2026
f1832a0
next handling and until overapproximated as f
Jun 8, 2026
855b4e6
x handling improvments
Jun 12, 2026
22d4c0b
or fix
Jun 24, 2026
0dc39d5
lp merge and binary operator nesting fixes
Jul 2, 2026
4cd9e38
restructured code and implemented hyperltl construction into the new …
Jul 30, 2026
8d0558d
small changes to potentially fix small performance loss
Aug 7, 2026
471ca63
working hyperltl lp + f merge
Sep 2, 2026
9b84dc3
merge main
Sep 2, 2026
b2c849f
new construction
Sep 23, 2026
bc79530
small change in f program compile rule
Sep 23, 2026
7417106
fixed U negation and some pointer errors
Sep 28, 2026
b3897dc
f rule + some performance improvements
Oct 4, 2026
bf2ce46
further generalizedf rule
Oct 10, 2026
e82b543
fixes for inconsistencies, improved X cases
Oct 11, 2026
8a12771
fixed invalid states by cloning timepoints
Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions include/PetriEngine/PQL/Contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "../Simplification/LPCache.h"
#include "../NetStructures.h"
#include "utils/structures/shared_string.h"
#include "PetriEngine/options.h"

#include "utils/errors.h"

Expand All @@ -36,6 +37,8 @@
#include <chrono>
#include <glpk.h>

#include <chrono>

namespace PetriEngine {

namespace PQL {
Expand Down Expand Up @@ -201,16 +204,22 @@ namespace PetriEngine {
};

class SimplificationContext {
struct simplificationRules{
bool G_rule = false;
bool F_rule = false;
bool X_rule = false;
};
public:

SimplificationContext(const MarkVal* marking,
const PetriNet* net, uint32_t queryTimeout, uint32_t lpTimeout,
const PetriNet* net, int num_paths, uint32_t queryTimeout, uint32_t lpTimeout, uint32_t lpPrintLevel,
Simplification::LPCache* cache, uint32_t potencyTimeout = 0)
: _queryTimeout(queryTimeout), _lpTimeout(lpTimeout),
: _queryTimeout(queryTimeout), _lpTimeout(lpTimeout), _lpPrintLevel(lpPrintLevel),
_potencyTimeout(potencyTimeout) {
_negated = false;
_marking = marking;
_net = net;
_num_paths = num_paths;
_base_lp = buildBase();
_start = std::chrono::high_resolution_clock::now();
_cache = cache;
Expand All @@ -220,8 +229,26 @@ namespace PetriEngine {
_markingOutOfBounds = true;
}
}

_isDeadlocked = _net->deadlocked(_marking);
_id = std::chrono::system_clock::now();
}

SimplificationContext(const MarkVal* marking,
const PetriNet* net, int num_paths, uint32_t queryTimeout, options_t& options,
Simplification::LPCache* cache)
: SimplificationContext(marking, net, num_paths, queryTimeout, options.lpsolveTimeout, options.lpPrintLevel, cache){
_rules = {options.useGRule, options.useFRule, options.useXRule};
_permutationLimit = static_cast<uint64_t>(options.permutationLimit);

}

SimplificationContext(const MarkVal* marking,
const PetriNet* net, uint32_t queryTimeout, uint32_t lpTimeout, uint32_t lpPrintLevel,
Simplification::LPCache* cache, uint32_t potencyTimeout = 0) : SimplificationContext(marking, net, 1, queryTimeout, lpTimeout, lpPrintLevel, cache, potencyTimeout){};

std::chrono::time_point<std::chrono::system_clock> _id;

virtual ~SimplificationContext() {
if(_base_lp != nullptr)
glp_delete_prob(_base_lp);
Expand All @@ -237,6 +264,10 @@ namespace PetriEngine {
return _markingOutOfBounds;
}

bool isDeadlocked() const {
return _isDeadlocked;
}

const PetriNet* net() const {
return _net;
}
Expand Down Expand Up @@ -269,20 +300,52 @@ namespace PetriEngine {

uint32_t getLpTimeout() const;
uint32_t getPotencyTimeout() const;
uint32_t getPrintLevel() const;

uint32_t numPaths() const{
return _num_paths;
}

uint32_t getNumBaseVariables() const{
return _num_paths * (_net->numberOfPlaces() + _net->numberOfTransitions());
}

uint32_t getNumBaseConstraints() const{
return _num_paths * _net->numberOfPlaces();
}

Simplification::LPCache* cache() const
{
return _cache;
}

const simplificationRules& rules() const
{
return _rules;
}

const uint64_t getPermutationLimit() const
{
return _permutationLimit;
}

void addAllPathConstraint(glp_prob* lp, size_t t, size_t l, int32_t* ind, double* col) const;
void addAllPathConstraint(glp_prob* lp, size_t t, size_t l, std::vector<int32_t>& ind, std::vector<double>& col) const;

glp_prob* makeBaseLP() const;

glp_prob* buildBaseFromMarking(std::vector<std::pair<std::vector<uint32_t>, double>>& setMarking) const;

private:
uint32_t _num_paths = 1;
simplificationRules _rules;
uint64_t _permutationLimit = 128;
bool _negated;
const MarkVal* _marking;
bool _markingOutOfBounds;
bool _isDeadlocked;
const PetriNet* _net;
uint32_t _queryTimeout, _lpTimeout, _potencyTimeout;
uint32_t _queryTimeout, _lpTimeout, _lpPrintLevel, _potencyTimeout;
mutable glp_prob* _base_lp = nullptr;
std::chrono::high_resolution_clock::time_point _start;
Simplification::LPCache* _cache;
Expand Down
19 changes: 19 additions & 0 deletions include/PetriEngine/PQL/Simplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ namespace PetriEngine { namespace PQL {
SimplificationContext& _context;
Retval _return_value;

enum LPOP {NONE, GLOBAL, FINAL, NEXT, UNTIL, OTHER, NULLT};
LPOP operator_found = LPOP::NONE;
LPOP operator_parent = LPOP::NONE;
bool op_parent_negated = false;
AbstractProgramCollection::temporalContext tcx;
int32_t operators = 0;

bool finalLpsImpossible(std::vector<AbstractProgramCollection_ptr>& final_lps);
bool finalLpsImpossibleAll(std::vector<AbstractProgramCollection_ptr>& final_lps);
bool nextLpsImpossible(std::vector<AbstractProgramCollection_ptr>& next_lps, std::vector<AbstractProgramCollection_ptr>& final_lps, bool is_invariant, bool is_or = false);
bool isNextImpossible(AbstractProgramCollection_ptr next_lps, bool strict);

Retval simplify_or(const LogicalCondition* element);
Retval simplify_and(const LogicalCondition *element);

Expand All @@ -50,9 +62,14 @@ namespace PetriEngine { namespace PQL {
Retval simplify_EF(Retval &r);
Retval simplify_EX(Retval &r);

Retval simplify_global_quantifier(Retval &r);

template <typename Quantifier>
Retval simplify_simple_quantifier(Retval &r);

template <typename Quantifier>
Retval simplify_simple_quantifier(Retval &r, bool strict);

void _accept(const NotCondition *element) override;

void _accept(const AndCondition *element) override;
Expand Down Expand Up @@ -113,6 +130,7 @@ namespace PetriEngine { namespace PQL {
};

Member memberForPlace(size_t p, const SimplificationContext &context);
Member memberForPathPlace(size_t p, int trace, const SimplificationContext &context);
Member constraint(const Expr *element, const SimplificationContext &context);

class ConstraintVisitor : public ExpressionVisitor {
Expand All @@ -123,6 +141,7 @@ namespace PetriEngine { namespace PQL {

private:
const SimplificationContext& _context;
int _current_path = 0;
Member _return_value;

void _accept(const LiteralExpr *element) override;
Expand Down
23 changes: 22 additions & 1 deletion include/PetriEngine/Simplification/LinearProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <memory>
#include <glpk.h>


namespace PetriEngine {
namespace Simplification {
using REAL = double;

struct equation_t
{
Expand All @@ -35,6 +37,17 @@ namespace PetriEngine {
enum result_t { UKNOWN, IMPOSSIBLE, POSSIBLE };
result_t _result = result_t::UKNOWN;
std::vector<equation_t> _equations;
// does the writing
static bool _writeEquationsImpl(glp_prob* lp, const PQL::SimplificationContext& context, int& rowno, std::vector<REAL>& row, std::vector<int32_t>& indir, const std::vector<equation_t>& equations, bool allocate, int32_t variable_shift = 0);
// adds rows to the lp, works from empty lp
static bool pushEquations(glp_prob* lp, const PQL::SimplificationContext& context, int& rowno, std::vector<REAL>& row, std::vector<int32_t>& indir, const std::vector<equation_t>& equations);
static bool pushEquationsShifted(glp_prob* lp, const PQL::SimplificationContext& context, int& rowno, std::vector<REAL>& row, std::vector<int32_t>& indir, const std::vector<equation_t>& equations, int32_t variable_shift = 0);
// does not add rows to the lp, requires pre-allocating
static bool emplaceEquations(glp_prob* lp, const PQL::SimplificationContext& context, int& rowno, std::vector<REAL>& row, std::vector<int32_t>& indir, const std::vector<equation_t>& equations);
static bool emplaceEquationsShifted(glp_prob* lp, const PQL::SimplificationContext& context, int& rowno, std::vector<REAL>& row, std::vector<int32_t>& indir, const std::vector<equation_t>& equations, int32_t variable_shift = 0);

static result_t solve_built_lp(glp_prob* lp, const PQL::SimplificationContext& context, uint32_t solvetime , bool delete_lp = true);
result_t solve_and_set(glp_prob* lp, const PQL::SimplificationContext& context, uint32_t solvetime, bool delete_lp = true);
public:
void swap(LinearProgram& other)
{
Expand Down Expand Up @@ -62,11 +75,19 @@ namespace PetriEngine {
bool knownImpossible() const { return _result == result_t::IMPOSSIBLE; }
bool knownPossible() const { return _result == result_t::POSSIBLE; }


bool isImpossible(const PQL::SimplificationContext& context, uint32_t solvetime);
bool isFinalImpossibleWith(const LinearProgram* withLp, bool is_next, bool is_strict, const PQL::SimplificationContext& context, uint32_t solvetime = std::numeric_limits<uint32_t>::max()) const;
bool isFinalImpossibleWithN(const std::vector<uint32_t>& permutation, const std::vector<LinearProgram*>& lps, bool is_next, bool is_strict, const PQL::SimplificationContext& context, uint32_t solvetime = std::numeric_limits<uint32_t>::max()) const;
bool isNStepsImpossible(double firelimit, bool strict, const PQL::SimplificationContext& context, uint32_t solvetime = std::numeric_limits<uint32_t>::max());
void solvePotency(const PQL::SimplificationContext& context, std::vector<uint32_t>& potencies);

static bool solveFinalConjunctionImpossible(std::vector<LinearProgram*>& lps, std::vector<std::vector<uint32_t>>& perms, std::vector<uint32_t>& starts,const PQL::SimplificationContext& context, uint32_t solvetime = std::numeric_limits<uint32_t>::max());
private:
static bool isFinalPermutationImpossible(glp_prob* lp, const std::vector<uint32_t>& permutation, const std::vector<LinearProgram*>& lps,const PQL::SimplificationContext& context, uint32_t solvetime = std::numeric_limits<uint32_t>::max());
public:
void make_union(const LinearProgram& other);

std::ostream& print(std::ostream& ss, size_t indent = 0) const
{
for (size_t i = 0; i < indent ; ++i) ss << "\t";
Expand Down
Loading
Loading