Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Represent and run a minion model in Rust #28

Merged
merged 10 commits into from
Oct 30, 2023

Conversation

niklasdewally
Copy link
Contributor

@niklasdewally niklasdewally commented Oct 28, 2023

I have a model running in Minion from a rust representation.

There are example problems for both the low level bindings and the Minion Rust AST versions inside raw_bindings.rs and run.rs respectively.

The work is very incomplete, things I still need to do (that I know about) are:

  • How to deal with boolean / non int constants
  • Memory management / freeing C++ stuff
  • I assume that variables used in the ast are defined in the symbol table, and if they aren't this could segfault.
  • Return Result instead of panicking
  • Callbacks and Solutions
  • Style and docs

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Oct 28, 2023

Feedback would be appreciated @ozgurakgun @ChrisJefferson @lixitrixi @Kieranoski702

(This can wait till Monday, I know I am working unsociable hours this week)

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Oct 28, 2023

No idea if the CI will work or not - as described in #27 minion is not threadsafe yet, but cargo tests run multithreaded

Tests run on host-server, haven't tested it on mac yet...

No outputs yet for the run.rs version , but there are logfiles that show that minion is doing stuff and getting solutions!

@niklasdewally niklasdewally mentioned this pull request Oct 28, 2023
1 task
@@ -1,7 +1,8 @@
// adapted from
// - https://github.com/gokberkkocak/rust_glucose/blob/master/build.rs
// e https://github.com/gokberkkocak/rust_glucose/blob/master/build.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just a typo?

@ChrisJefferson
Copy link
Contributor

I think this is quite good, and it would be nice to merge, because while lots of things still need doing, it gives us all a base for hacking on, where things run "end to end".

@ChrisJefferson
Copy link
Contributor

To deal specifically with the crashing issue, I'd suggest changing the start of runMinion in libwrapper.cpp to look like this:

std::mutex global_minion_lock;
ReturnCodes runMinion(SearchOptions& options, SearchMethod& args, ProbSpec::CSPInstance& instance, bool(*callback)(void)) {
  std::lock_guard<std::mutex> guard(global_minion_lock);

This just makes a global mutex, and then locks it while in runMinion. This stops multiple calls to runMinion running at once (obviously). C++ is quite good at cleaning up (the mutex should be automatically unlocked when this function exits), so this should create problems even if minion exits with an error.

@ozgurakgun
Copy link
Contributor

or should I? this is still marked as a draft?

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Oct 30, 2023

or should I? this is still marked as a draft?

As long as you are happy with this still referencing my dev branch of minion, it can be merged.
(I havent quite finished with the C++ side of this)

@niklasdewally
Copy link
Contributor Author

Might be good to hack over later

@niklasdewally niklasdewally marked this pull request as ready for review October 30, 2023 13:03
Copy link
Contributor

@ozgurakgun ozgurakgun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor comments

@niklasdewally
Copy link
Contributor Author

@ozgurakgun I've renamed those things suggested.

@ozgurakgun ozgurakgun merged commit 515d869 into conjure-cp:main Oct 30, 2023
10 checks passed
@niklasdewally niklasdewally deleted the minion-bindings branch November 2, 2023 19:23
@niklasdewally niklasdewally restored the minion-bindings branch November 2, 2023 19:23
@niklasdewally niklasdewally deleted the minion-bindings branch November 2, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants