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

Tijl/ /rc calendar #431

Merged
merged 160 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
c3b2bad
remove Flexibility concept
Dec 31, 2023
8c61589
remove Day DayFilter and Date
Dec 31, 2023
c362f62
delete legacy folder
Dec 31, 2023
b25a060
remove unused script
Dec 31, 2023
4ae1a30
update doc example
Dec 31, 2023
8d22bf1
keep todos in the code or in issues
Jan 1, 2024
5aa830f
starting to import json correctly
Jan 1, 2024
88fe24e
add goals back
Jan 1, 2024
b2402d5
add services
Jan 1, 2024
d04e8bd
remove unused utilities
Jan 2, 2024
2b85803
move input to separate area
Jan 2, 2024
3a84335
add Budget and activity_placer
Jan 2, 2024
b22866a
remove unused crate soft
Jan 2, 2024
b5ef84f
remove unused imports
Jan 2, 2024
3b21970
moved technical non-domain concerns away
Jan 2, 2024
7c76e6c
generate activites from goals
Jan 2, 2024
c8046eb
add status to Activity
Jan 2, 2024
0df8c64
added Activity.flex() and custom Debug
Jan 2, 2024
9dab4bd
scheduling algorithm-challenge
Jan 2, 2024
b6ff2cc
hide print statements for readability
Jan 2, 2024
60cf39a
attempt to generate tests correctly
Jan 2, 2024
43f6bc6
budget only needs a max - which is also the min.
Jan 2, 2024
0c8990a
add FinalTasks struct
Jan 3, 2024
fb015a9
release claims when Activity is scheduled
Jan 3, 2024
f7c4748
trying to generate FinalTasks
Jan 3, 2024
4eeb0e5
rename Occupied activity_index
Jan 3, 2024
ec4b98b
output FinalTasks
Jan 3, 2024
6be17a6
format expected in same way as output for easy file compare
Jan 3, 2024
e7e4853
Passing algo challenge with cargo t
Jan 3, 2024
9bcdce2
input uses list of goals now
Jan 4, 2024
8dc66ef
format expected
Jan 4, 2024
d637acf
Escape invalid doctest
Jan 4, 2024
fe59e23
fix init of goalid for free
Jan 4, 2024
6b90458
basic_1 passing
Jan 4, 2024
194c543
Add todo
Jan 4, 2024
f21b9c8
convert alg-challenge input to new format => red test
Jan 4, 2024
69bdb77
update input to new format
Jan 4, 2024
9b54837
fix for new input format
Jan 4, 2024
467f65a
add sleep-1 budget test => red
Jan 4, 2024
0cd12d1
fix missing start/deadline
Jan 4, 2024
a0a8aff
JS input should be camelCased
Jan 4, 2024
79b8fcd
format expected
Jan 4, 2024
6e8fed7
JS input is camelCase
Jan 4, 2024
08d8550
budget goals loading
Jan 4, 2024
53f1e65
remove todo that is done
Jan 4, 2024
149cefd
fix compatible hours filter for budget goal
Jan 4, 2024
67c71fe
scheduling algo-challenge on wrong day
Jan 5, 2024
1422a3c
algo/basic green again - sleep inverted and not multi-day yet...
Jan 5, 2024
b113b78
correct error in input start
Jan 5, 2024
0762235
rename hour_index
Jan 5, 2024
24324dd
filter for hour_of_day
Jan 5, 2024
b3822ee
remove unnecessary var
Jan 5, 2024
9123d50
adjust start/deadline for budget activities
Jan 5, 2024
4928b59
fix Task counter
Jan 5, 2024
e3ba48c
adjust Task.deadline dynamically
Jan 5, 2024
bdefc48
add explain comment
Jan 5, 2024
ab6abd4
splitting calendar output on day boundary
Jan 5, 2024
2a2b69f
make gen_activities return a Vec<Act>
Jan 5, 2024
fb01ec5
remove TODO that was done
Jan 5, 2024
c3d5076
extract function for readability
Jan 5, 2024
01b40f2
make loop for generating activities
Jan 5, 2024
3c0bba1
improve calendar output loop
Jan 5, 2024
806a449
correct input
Jan 5, 2024
4bb0377
add right number of activities for budget
Jan 5, 2024
d750b93
passing sleep-1 too
Jan 5, 2024
7538b54
remove sleep-1 from validated
Jan 5, 2024
4ffe5e0
add test default-budgets => red
Jan 6, 2024
b1b6b03
remove empty fields
Jan 6, 2024
1c5e7cd
add default for missing start/deadline
Jan 6, 2024
363a355
JS should be camelCase
Jan 6, 2024
99c2c63
improve calendar debug print
Jan 6, 2024
a1c8b93
adjust goal start/deadline if default
Jan 6, 2024
a3fac57
add children and skip if some
Jan 6, 2024
8fccd36
remove unused imports
Jan 6, 2024
dfc691b
separate activity generation per goal type
Jan 7, 2024
73f1b71
simplify simple goal handling
Jan 7, 2024
99f2681
remove unnecessary ifs
Jan 7, 2024
2d54aaa
typo
Jan 7, 2024
7eedc10
simplify generating activities from budget goal
Jan 7, 2024
a08c403
default_goals producing output
Jan 7, 2024
f5bb172
add Todo's for next session
Jan 7, 2024
dfb184f
remove unused file
Jan 7, 2024
1524ac1
make wasm run again
Jan 7, 2024
7127fe4
add on_days to input
Jan 7, 2024
ea1a09c
update input with recent version from dev
Jan 8, 2024
3b30ff8
add day filter
Jan 8, 2024
3e09450
build wasm
Jan 8, 2024
492102f
mark activity impossible if no best_hour_index
Jan 8, 2024
9724c4d
update observed for new input file
Jan 8, 2024
63e492b
Introduce ImpossibleActivity
Jan 8, 2024
cb916e2
test case simple goal without start/deadline
Jan 8, 2024
29828b3
adjust expectation
Jan 8, 2024
287ffb3
fix erroneous default star/deadline for simple goal
Jan 8, 2024
94632a8
correct error message
Jan 8, 2024
d6083c7
remove debug prints
Jan 8, 2024
e6e0280
improve calendar panic print
Jan 8, 2024
507cebc
fix off by one
Jan 8, 2024
f04e1ab
fix first day of calendar empty
Jan 8, 2024
129fcf6
gitignore private goals
Jan 9, 2024
11b5e62
only create activities for on_days
Jan 9, 2024
63018e6
use goals as ref
Jan 13, 2024
55a4740
use calendar as mut ref
Jan 13, 2024
fd5fe58
split scheduling in two phases
Jan 13, 2024
bcdf24e
separate calendar printing from activity placing
Jan 13, 2024
6d24519
start setting up budgets
Jan 13, 2024
4fbe254
factor out adjusting goal start/deadline
Jan 13, 2024
03bf952
give Activity Vec<Budget>
Jan 13, 2024
cedf663
better name fn
Jan 13, 2024
c637f7d
get all descendants for each budget
Jan 13, 2024
55ee708
add time_budgets to budget
Jan 14, 2024
fdc966a
handling reducing budgets for creating optional
Jan 14, 2024
5e4ba3c
use time_budget in activity scope - not budget
Jan 14, 2024
b2a4235
remove done todo
Jan 14, 2024
bf94d49
let calendar handle updating budgets
Jan 14, 2024
819a12c
budgets on cal don't need to be a map
Jan 14, 2024
f58ae58
debug print for Budgets
Jan 14, 2024
bfd5cb7
budgets being updated
Jan 14, 2024
ccc0d2e
placeholder for optional budget activities
Jan 14, 2024
61c750f
document respect max budget approach
Jan 14, 2024
4e40b1f
measure week budget from official start of calendar
Jan 14, 2024
f199822
measure day budgets from official start of calendar
Jan 14, 2024
f6a3a1a
further refine respect max budgets approach
Jan 14, 2024
3215649
remove unused function
Jan 14, 2024
49439f7
limiting scheduling on max_per_day/week
Jan 14, 2024
d60693d
fix one time_budget at max wiping all activity overlays
Jan 14, 2024
738c8f0
cleanup comments
Jan 14, 2024
3f05a40
remove done todo
Jan 14, 2024
4b88455
elaborate todo about unnecessary impossible
Jan 14, 2024
0b81996
remove marking budget activities as impossible prematurely
Jan 14, 2024
6119483
mark todo done
Jan 14, 2024
0556244
add todo : respect min / week as max in first round
Jan 14, 2024
5d21b14
done: choose budget limit according to activity_type
Jan 14, 2024
60eed52
added todo's in lib an budget
Jan 14, 2024
4a54800
fix todo log_impossible_min_day_budgets
Jan 16, 2024
9b76428
add one activity/day to get to min week
Jan 16, 2024
5eedf83
factor out generate activity fn
Jan 16, 2024
a5edb58
add multiple get_to_min_week activities
Jan 16, 2024
3e6fb1e
test log impossible min_per_week works
Jan 16, 2024
b38e248
restore test without failin min_per_week
Jan 16, 2024
5c899c9
remove done todo
Jan 16, 2024
006d99e
top up week budgets
Jan 16, 2024
939682d
update expected to cluster tasks with after>before
Jan 16, 2024
5e02035
add TODO test cases
Jan 16, 2024
f43b83d
fixed all but one clippy warning
Jan 19, 2024
3e57e32
fixed last clippy
Jan 19, 2024
718f92b
set day budget min/max to 0 if not in on_days
Jan 19, 2024
78bcbef
mark todo done
Jan 19, 2024
a9a211d
add TODOs for budget correctness check
Jan 19, 2024
7ccb011
add panic for inconsistent budget config
Jan 20, 2024
75a224d
mark todo done inconsistent min/week
Jan 20, 2024
93504d9
fix input to be realistic - and fix error in panic
Jan 20, 2024
07c5cdb
add second check on budget quality
Jan 20, 2024
49431c1
Update expected.json based on new input
Jan 20, 2024
3395668
optimize debug output
Jan 21, 2024
50678e6
adjust goal placing start/end indexes when after > before
Jan 21, 2024
a3c74a6
fix nasty off-by-one bug
Jan 21, 2024
6a9d0bf
update tests to log impossible min/week
Jan 21, 2024
3d83acd
allow multiple and larger blocks from single activity
Jan 21, 2024
060266e
update expectation and observed default_goals
Jan 21, 2024
49920f9
fix clippy
Jan 21, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target/
tests/rust_tests.rs
_logs/
js-api/
tests/jsons/stable/tijl-goals
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ with-logging = []

new-tests = []

default = [ "new-tests", "with-logging" ]
default = ["new-tests", "with-logging"]

[lib]
#see https://github.com/rust-lang/cargo/issues/6659#issuecomment-463335095
Expand Down Expand Up @@ -54,9 +54,6 @@ console_error_panic_hook = "0.1.7"
log = "0.4.19"
env_logger = "0.10.0"

# soft assertions without panic
soft = "0.1.1"

# random number generator for tests
rand = "0.8.5"
# getrandom with js features should be included to make sure the wasm-unknown build target can use the crate in js context (even though we only use this crate in test code)
Expand Down
4 changes: 2 additions & 2 deletions build_templates/run_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![cfg_attr(rustfmt, rustfmt_skip)] //skip cargo fmt on autogenerated file

extern crate scheduler;
extern crate soft;
mod common;
use scheduler::technical::input_output::Input;
use scheduler::models::calendar;

/// AUTO-GENERATED FILE. Do not change.
/// Will be overwritten on build. Edit the file in build_templates or change test generation in build.rs
Expand Down
55 changes: 46 additions & 9 deletions build_templates/tests_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
mod TEST_MODULE_NAME {

// stable tests
//TEST_FUNCTIONS_STABLE
//TEST_FUNCTIONS_STABLE

// experimental tests
//TEST_FUNCTIONS_EXPERIMENTAL
//TEST_FUNCTIONS_EXPERIMENTAL

use scheduler::legacy::{input::Input, output::FinalTasks};
use crate::calendar::Calendar;
use crate::Input;
use scheduler::models::activity::Activity;
use scheduler::services::{activity_generator, activity_placer};

use scheduler::technical::input_output;
use std::path::Path;
use crate::common;


fn test(folder: &str) {
let (actual_output, desired_output) = generate_outputs(folder);
assert_eq!(actual_output, desired_output);
Expand All @@ -26,13 +30,46 @@ mod TEST_MODULE_NAME {
let output_path = Path::new(&output_path_str[..]);
let actual_output_path = Path::new(&actual_output_path_str[..]);

let input: Input = common::get_input_from_json(input_path).unwrap();
let desired_output: String = common::get_output_string_from_json(output_path).unwrap();
let input: Input = input_output::get_input_from_json(input_path).unwrap();
let desired_output: String =
input_output::get_output_string_from_json(output_path).unwrap();

// ONLY do this if expected is malformatted ... check that contents don't change!
// input_output::write_to_file(output_path, &desired_output).unwrap();

let mut calendar = Calendar::new(input.start_date, input.end_date);

calendar.add_budgets_from(&input.goals);

//generate and place simple goal activities
let simple_goal_activities =
activity_generator::generate_simple_goal_activities(&calendar, &input.goals);
dbg!(&simple_goal_activities);
activity_placer::place(&mut calendar, simple_goal_activities);

//generate and place budget goal activities
let budget_goal_activities: Vec<Activity> =
activity_generator::generate_budget_goal_activities(&calendar, &input.goals);
dbg!(&calendar);
activity_placer::place(&mut calendar, budget_goal_activities);

calendar.log_impossible_min_day_budgets();

let get_to_week_min_budget_activities =
activity_generator::generate_get_to_week_min_budget_activities(&calendar, &input.goals);
activity_placer::place(&mut calendar, get_to_week_min_budget_activities);

calendar.log_impossible_min_week_budgets();

let top_up_week_budget_activities =
activity_generator::generate_top_up_week_budget_activities(&calendar, &input.goals);
activity_placer::place(&mut calendar, top_up_week_budget_activities);

let output = calendar.print();

let output: FinalTasks = scheduler::run_scheduler(input);
let actual_output = serde_json::to_string_pretty(&output).unwrap();

common::write_to_file(actual_output_path, &actual_output).unwrap();
input_output::write_to_file(actual_output_path, &actual_output).unwrap();

(actual_output, desired_output)
}
Expand Down
23 changes: 22 additions & 1 deletion pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@
If you like Rust and scheduling algorithms you've come to the right place :) We
can talk big-O, add features or optimize hot loops.

> Please contact me [email protected] or open an issue.
> Please contact me [email protected] or open an issue.


## ZinZen&reg;
ZinZen&reg; is a platform for stress-free life planning. It works by defining life goals with constraints and dependencies.
An automatic scheduler then schedules tasks in a calendar to reach these goals, auto-magically updating the schedule when
goals or constraints change.

This repository contains the ZinZen&reg;-scheduler. The scheduler consists of a WASM-module written in Rust
that can be called from the React-based UI application.

The ZinZen&reg; UI application can be found here: [ZinZen&reg; Github](https://github.com/tijlleenders/ZinZen)



## Getting started
All documentation can be found in the folder [documentation](documentation/Readme.md).
In this folder you will find a [technical know-how base](documentation/technical/Readme.md),
as well as all the necessary [functional documentation](documentation/functional/Readme.md) to understand the
scheduling algorithms and all the concepts introduced in the ZinZen&reg;-scheduler.

For a quick set-up guide see the [Development Setup page](documentation/technical/Development-Setup.md).

## Legal stuff

Expand Down
8 changes: 5 additions & 3 deletions pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zinzen",
"description": "Algorithm for auto-scheduling time-constrained tasks on a timeline",
"version": "0.1.0",
"version": "0.2.0",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand All @@ -14,9 +14,11 @@
"LICENSE.md"
],
"module": "scheduler.js",
"homepage": "https://github.com/tijlleenders/ZinZen-scheduler/wiki",
"homepage": "https://github.com/tijlleenders/ZinZen-scheduler",
"types": "scheduler.d.ts",
"sideEffects": false,
"sideEffects": [
"./snippets/*"
],
"keywords": [
"zinzen",
"scheduler",
Expand Down
17 changes: 11 additions & 6 deletions pkg/scheduler.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* The main wasm function to call
* @param {any} input
* @returns {any}
*/
Expand All @@ -19,19 +20,23 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly schedule: (a: number, b: number) => void;
readonly __wbindgen_malloc: (a: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Synchronously compiles the given `bytes` and instantiates the WebAssembly module.
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {BufferSource} bytes
* @param {SyncInitInput} module
*
* @returns {InitOutput}
*/
export function initSync(bytes: BufferSource): InitOutput;
export function initSync(module: SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
Expand All @@ -41,4 +46,4 @@ export function initSync(bytes: BufferSource): InitOutput;
*
* @returns {Promise<InitOutput>}
*/
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading
Loading