Boot function
This commit is contained in:
parent
467f3193b2
commit
fa0cdee811
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
mod algo;
|
mod algo;
|
||||||
|
|
||||||
use bgtu_ai_utility::labeled_slider;
|
use bgtu_ai_utility::gui::{boot_eframe, labeled_slider};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use eframe::egui::{CornerRadius, Frame};
|
use eframe::egui::{CornerRadius, Frame};
|
||||||
use eframe::epaint::{Color32, Pos2, Rect};
|
use eframe::epaint::{Color32, Pos2, Rect};
|
||||||
@ -10,15 +10,7 @@ use rand::SeedableRng;
|
|||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
let options = eframe::NativeOptions {
|
return boot_eframe(||MyApp::new())
|
||||||
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 400.0]),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
eframe::run_native(
|
|
||||||
"Annealing Simulation for Chess Queens Task",
|
|
||||||
options,
|
|
||||||
Box::new(|_cc| Ok(Box::<MyApp>::default())),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MyApp {
|
struct MyApp {
|
||||||
@ -28,9 +20,9 @@ struct MyApp {
|
|||||||
result: Option<algo::Board>,
|
result: Option<algo::Board>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MyApp {
|
impl MyApp {
|
||||||
fn default() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
return Self {
|
||||||
simulationConfig: algo::AnnealingConfig {
|
simulationConfig: algo::AnnealingConfig {
|
||||||
initialTemperature: 30.0,
|
initialTemperature: 30.0,
|
||||||
targetTemperature: 0.5,
|
targetTemperature: 0.5,
|
||||||
|
|||||||
@ -3,20 +3,12 @@
|
|||||||
mod algo;
|
mod algo;
|
||||||
|
|
||||||
use crate::algo::BitVector;
|
use crate::algo::BitVector;
|
||||||
use bgtu_ai_utility::labeled_slider;
|
use bgtu_ai_utility::gui::{boot_eframe, labeled_slider};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui_extras::{Column, TableBuilder};
|
use egui_extras::{Column, TableBuilder};
|
||||||
|
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
let options = eframe::NativeOptions {
|
return boot_eframe(|| MyApp::new());
|
||||||
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 400.0]),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
eframe::run_native(
|
|
||||||
"Adaptive Resonance Theory calculater",
|
|
||||||
options,
|
|
||||||
Box::new(|_cc| Ok(Box::<MyApp>::default())),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UpdatePending {
|
enum UpdatePending {
|
||||||
@ -36,8 +28,8 @@ struct MyApp {
|
|||||||
rowUpdate: UpdatePending,
|
rowUpdate: UpdatePending,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MyApp {
|
impl MyApp {
|
||||||
fn default() -> Self {
|
fn new() -> Self {
|
||||||
return Self {
|
return Self {
|
||||||
_isFirstFrame: true,
|
_isFirstFrame: true,
|
||||||
bitCount: 0,
|
bitCount: 0,
|
||||||
|
|||||||
@ -8,23 +8,16 @@ use crate::algo::{
|
|||||||
};
|
};
|
||||||
use bgtu_ai_utility::gui::lengths_table::{draw_lengths_table, UpdatePending};
|
use bgtu_ai_utility::gui::lengths_table::{draw_lengths_table, UpdatePending};
|
||||||
use bgtu_ai_utility::gui::render::render_graph;
|
use bgtu_ai_utility::gui::render::render_graph;
|
||||||
use bgtu_ai_utility::labeled_slider;
|
use bgtu_ai_utility::gui::{boot_eframe, labeled_slider};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use eframe::egui::{Frame, Ui};
|
use eframe::egui::{Frame, Ui};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
let options = eframe::NativeOptions {
|
return boot_eframe(|| MyApp::new());
|
||||||
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 400.0]),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
eframe::run_native(
|
|
||||||
"Ants simulation",
|
|
||||||
options,
|
|
||||||
Box::new(|_cc| Ok(Box::<MyApp>::default())),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum GlobalState {
|
enum GlobalState {
|
||||||
Edit,
|
Edit,
|
||||||
Running,
|
Running,
|
||||||
@ -39,8 +32,8 @@ struct MyApp {
|
|||||||
ants_per_vertex: usize,
|
ants_per_vertex: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MyApp {
|
impl MyApp {
|
||||||
fn default() -> Self {
|
fn new() -> Self {
|
||||||
return Self {
|
return Self {
|
||||||
simulation: AntsSimulationState {
|
simulation: AntsSimulationState {
|
||||||
edges: EdgesVec::new(),
|
edges: EdgesVec::new(),
|
||||||
|
|||||||
@ -5,24 +5,17 @@
|
|||||||
mod algo;
|
mod algo;
|
||||||
|
|
||||||
use crate::algo::{gen_images, ComparationOperatorsModel};
|
use crate::algo::{gen_images, ComparationOperatorsModel};
|
||||||
use bgtu_ai_utility::labeled_slider;
|
use bgtu_ai_utility::gui::{boot_eframe, labeled_slider};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use eframe::egui::Widget;
|
use eframe::egui::Widget;
|
||||||
use egui_extras::{Column, TableBuilder};
|
use egui_extras::{Column, TableBuilder};
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
let options = eframe::NativeOptions {
|
return boot_eframe(|| MyApp::new());
|
||||||
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 400.0]),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
eframe::run_native(
|
|
||||||
"Neural net",
|
|
||||||
options,
|
|
||||||
Box::new(|_cc| Ok(Box::<MyApp>::default())),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum TrainingState {
|
enum TrainingState {
|
||||||
NoTrain,
|
NoTrain,
|
||||||
Training {
|
Training {
|
||||||
@ -42,8 +35,8 @@ struct MyApp {
|
|||||||
compute_result: [f64; 8],
|
compute_result: [f64; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MyApp {
|
impl MyApp {
|
||||||
fn default() -> Self {
|
fn new() -> Self {
|
||||||
let imgs = gen_images();
|
let imgs = gen_images();
|
||||||
return Self {
|
return Self {
|
||||||
model: ComparationOperatorsModel::new(imgs.1),
|
model: ComparationOperatorsModel::new(imgs.1),
|
||||||
|
|||||||
13
utility/src/gui/boot.rs
Normal file
13
utility/src/gui/boot.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use eframe::egui;
|
||||||
|
|
||||||
|
pub fn boot_eframe<T: eframe::App>(init_data: impl FnOnce() -> T) ->eframe::Result {
|
||||||
|
let options = eframe::NativeOptions {
|
||||||
|
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 400.0]),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
eframe::run_native(
|
||||||
|
"Annealing Simulation for Chess Queens Task",
|
||||||
|
options,
|
||||||
|
Box::new(|_cc| Ok(Box::<T>::new(init_data()))),
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::graph::{EdgesVec, VerticesVec};
|
use crate::graph::{EdgesVec, VerticesVec};
|
||||||
use crate::slider;
|
use crate::gui::slider;
|
||||||
use eframe::egui::{ScrollArea, Ui};
|
use eframe::egui::{ScrollArea, Ui};
|
||||||
use egui_extras::{Column, TableBuilder};
|
use egui_extras::{Column, TableBuilder};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|||||||
@ -1,2 +1,7 @@
|
|||||||
pub mod lengths_table;
|
pub mod lengths_table;
|
||||||
pub mod render;
|
pub mod render;
|
||||||
|
mod slider;
|
||||||
|
mod boot;
|
||||||
|
|
||||||
|
pub use slider::{slider, labeled_slider};
|
||||||
|
pub use boot::boot_eframe;
|
||||||
@ -1,5 +1,3 @@
|
|||||||
pub mod graph;
|
pub mod graph;
|
||||||
pub mod gui;
|
pub mod gui;
|
||||||
mod slider;
|
|
||||||
|
|
||||||
pub use slider::{slider, labeled_slider};
|
|
||||||
Loading…
Reference in New Issue
Block a user