Skip to content

Commit

Permalink
submit command extracts a-number
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrause committed Mar 11, 2022
1 parent 84807b7 commit 2bb12b5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ To install or update LODA, please follow the [installation instructions](https:/

## [Unreleased]

### Enhancements

* Incremental evaluation (IE) partially supports programs with non-commutative updates of output cells. IE is supported for 5200 programs now.
* Store default values in `setup.txt`
## v22.3.11

### Features

* Parallel mining with custom number of instances: `-P <number>`
* Short-hand parameter for b-file output with offset 0: `-b`
* `submit` command extracts A-number from comment in programs

### Enhancements

* Incremental evaluation (IE) partially supports programs with non-commutative updates of output cells. IE is supported for 5200 programs now.
* Store default values in `setup.txt`

## v22.2.17

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To mine programs for OEIS sequences, you can run `loda mine` (single-core) or `l
The `loda` command-line tool provides the following commands and options:

```
Welcome to LODA developer version. More information at https://loda-lang.org
Welcome to LODA developer version. More information at https://loda-lang.org/
Usage: loda <command> <options>
Expand All @@ -37,9 +37,9 @@ Core Commands:
setup Run interactive setup to configure LODA
OEIS Commands:
mine Mine programs for OEIS sequences (see -i)
mine Mine programs for OEIS sequences (see -i,-p)
check <id> Check a program for an OEIS sequence (see -b)
submit <id> <file> Submit a program for an OEIS sequence
submit <file> [id] Submit a program for an OEIS sequence
Targets:
<file> Path to a LODA file (file extension: *.asm)
Expand All @@ -48,12 +48,15 @@ Targets:
Options:
-t <number> Number of sequence terms (default: 10)
-b <number> Print result in b-file format from a given offset
-b Print result in b-file format from offset 0
-B <number> Print result in b-file format from a custom offset
-s Evaluate program to number of execution steps
-c <number> Maximum number of interpreter cycles (no limit: -1)
-m <number> Maximum number of used memory cells (no limit: -1)
-l <string> Log level (values: debug,info,warn,error,alert)
-i <string> Name of miner configuration from miners.json
-p Parallel mining using default number of instances
-P <number> Parallel mining using custom number of instances
```

### Core Commands
Expand Down
6 changes: 3 additions & 3 deletions src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Commands::help() {
std::cout << " check <id> Check a program for an OEIS sequence "
"(see -b)"
<< std::endl;
std::cout << " submit <id> <file> Submit a program for an OEIS sequence"
std::cout << " submit <file> [id] Submit a program for an OEIS sequence"
<< std::endl;
std::cout << std::endl << "Targets:" << std::endl;
std::cout
Expand Down Expand Up @@ -168,10 +168,10 @@ void Commands::mine() {
miner.mine();
}

void Commands::submit(const std::string& id, const std::string& path) {
void Commands::submit(const std::string& path, const std::string& id) {
initLog(false);
Miner miner(settings);
miner.submit(id, path);
miner.submit(path, id);
}

// hidden commands (only in development versions)
Expand Down
2 changes: 1 addition & 1 deletion src/include/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Commands {

void mine();

void submit(const std::string& id, const std::string& path);
void submit(const std::string& path, const std::string& id);

// hidden commands (only in development versions)

Expand Down
2 changes: 1 addition & 1 deletion src/include/miner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Miner {

void mine();

void submit(const std::string &id, const std::string &path);
void submit(const std::string &path, std::string id);

private:
void checkRegularTasks();
Expand Down
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ int dispatch(Settings settings, const std::vector<std::string>& args) {
commands.mine();
}
} else if (cmd == "submit") {
if (args.size() != 3) {
if (args.size() == 2) {
commands.submit(args.at(1), "");
} else if (args.size() == 3) {
commands.submit(args.at(1), args.at(2));
} else {
std::cout << "invalid number of arguments" << std::endl;
return 1;
}
commands.submit(args.at(1), args.at(2));
}
#ifdef _WIN64
// hidden helper command for updates on windows
Expand Down
9 changes: 8 additions & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,18 @@ void Miner::checkRegularTasks() {
}
}

void Miner::submit(const std::string &id, const std::string &path) {
void Miner::submit(const std::string &path, std::string id) {
Parser parser;
auto program = parser.parse(path);
ConfigLoader::MAINTAINANCE_MODE = true;
reload();
if (id.empty() && program.ops.size() > 0 && !program.ops[0].comment.empty()) {
id = program.ops[0].comment;
auto n = id.find(':');
if (n != std::string::npos) {
id = id.substr(0, n);
}
}
OeisSequence seq(id);
Settings settings(this->settings);
settings.print_as_b_file = false;
Expand Down

0 comments on commit 2bb12b5

Please sign in to comment.