pub mod benchmarks;
pub mod citations;
pub mod collaboration;
pub mod conferences;
pub mod datasets;
pub mod experiments;
pub mod funding;
pub mod peer_review;
pub mod publications;
pub mod reproducibility;
pub use benchmarks::*;
pub use collaboration::*;
pub use datasets::*;
pub use funding::*;
pub use experiments::{
CpuInfo, DataType, DatasetInfo, DatasetStatistics, EarlyStoppingConfig, Experiment,
ExperimentConfig, ExperimentMetadata, ExperimentNote, ExperimentResult, ExperimentRunner,
ExperimentStatus, ExperimentTimeline, GpuInfo, HardwareConfig as ExperimentHardwareConfig,
MemoryAllocationStrategy, MemoryConfig, NoteType, OptimizationMode, ParallelConfig,
PreprocessingStep, ReproducibilityChecklist, ReproducibilityInfo, ResourceMonitor,
ResourceUsage, RunStatus, SystemInfo as ExperimentSystemInfo, TrainingHistory,
};
pub use reproducibility::{
CpuSpec, Dependency, Difference, DifferenceCategory, EnvironmentSnapshot, GpuSpec,
HardwareConfig as ReproducibilityHardwareConfig, IssueSeverity, IssueType, MemorySpec,
ReproducibilityChecklist as ReproducibilityChecklistType, ReproducibilityConfig,
ReproducibilityIssue, ReproducibilityManager, ReproducibilityReport, ReproducibilityStorage,
SimilarityMetrics, StorageSpec, SystemInfo as ReproducibilitySystemInfo, VerificationResult,
VerificationStatus,
};
pub use citations::{
Author as CitationAuthor, BibliographyFormat, Citation, CitationManager,
CitationStyle as CitationStyleType, DateFormat, FormattingRules, InTextFormat, NameFormat,
PublicationType as CitationPublicationType, PunctuationRules, SortDirection, SortField,
SortingRules, TitleFormat,
};
pub use publications::{
Affiliation, Author as PublicationAuthor, AuthorPosition, BibTeXEntry, Bibliography,
CitationStyle as PublicationCitationStyle, Decision, Figure, FigureType, ManuscriptSection,
Publication, PublicationStatus, PublicationType as PublicationTypeEnum,
Review as PublicationReview, ReviewRecommendation as PublicationReviewRecommendation,
ReviewerInfo, SectionType, SubmissionRecord, SubmissionStatus, Table, Venue, VenueType,
};
pub use peer_review::{
MetaReview, PeerReview, PeerReviewSystem, ReviewAssignment, ReviewCriterion, ReviewDiscussion,
ReviewQualityAssessment, ReviewQualityMetric, ReviewRecommendation as PeerReviewRecommendation,
ReviewSession, ReviewSessionStatus, ReviewStatus, ReviewType, Reviewer, ReviewerAvailability,
ReviewerHistory, ReviewerPreferences, ReviewerQualityMetrics, WrittenReview,
};
pub use conferences::{
Conference, ConferenceDates, ConferenceManager, DeadlineType, Review as ConferenceReview,
ReviewFormat, ReviewProcess, ReviewRecommendation as ConferenceReviewRecommendation,
Submission, SubmissionStatus as ConferenceSubmissionStatus,
};
use crate::error::{OptimError, Result};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResearchProject {
pub name: String,
pub description: String,
pub research_area: ResearchArea,
pub status: ProjectStatus,
pub researchers: Vec<Researcher>,
pub funding: Option<FundingInfo>,
pub timeline: ProjectTimeline,
pub experiments: Vec<Experiment>,
pub publications: Vec<Publication>,
pub settings: ProjectSettings,
pub created_at: DateTime<Utc>,
pub modified_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ResearchArea {
MachineLearning,
DeepLearning,
OptimizationTheory,
ComputerVision,
NaturalLanguageProcessing,
ReinforcementLearning,
ScientificComputing,
HighPerformanceComputing,
DistributedSystems,
QuantumComputing,
Interdisciplinary,
Other(String),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ProjectStatus {
Planning,
Active,
DataCollection,
Analysis,
Writing,
UnderReview,
Published,
Completed,
OnHold,
Cancelled,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Researcher {
pub name: String,
pub email: String,
pub affiliation: String,
pub orcid: Option<String>,
pub role: ResearcherRole,
pub expertise: Vec<String>,
pub contact_info: ContactInfo,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ResearcherRole {
PrincipalInvestigator,
CoPrincipalInvestigator,
SeniorResearcher,
Postdoc,
PhDStudent,
MastersStudent,
UndergraduateStudent,
ResearchAssistant,
Collaborator,
Advisor,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ContactInfo {
pub phone: Option<String>,
pub office_address: Option<String>,
pub mailing_address: Option<String>,
pub website: Option<String>,
pub social_media: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FundingInfo {
pub agency: String,
pub grant_number: String,
pub grant_title: String,
pub amount: Option<f64>,
pub currency: String,
pub start_date: DateTime<Utc>,
pub end_date: DateTime<Utc>,
pub award_date: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectTimeline {
pub start_date: DateTime<Utc>,
pub planned_end_date: DateTime<Utc>,
pub actual_end_date: Option<DateTime<Utc>>,
pub milestones: Vec<Milestone>,
pub progress_updates: Vec<ProgressUpdate>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Milestone {
pub name: String,
pub description: String,
pub planned_date: DateTime<Utc>,
pub completed_date: Option<DateTime<Utc>>,
pub status: MilestoneStatus,
pub deliverables: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum MilestoneStatus {
NotStarted,
InProgress,
Completed,
Delayed,
Cancelled,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProgressUpdate {
pub timestamp: DateTime<Utc>,
pub author: String,
pub summary: String,
pub description: String,
pub completion_percentage: f64,
pub next_steps: Vec<String>,
pub challenges: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectSettings {
pub enable_reproducibility: bool,
pub enable_backups: bool,
pub backup_frequency_hours: u32,
pub data_retention_days: u32,
pub privacy_settings: PrivacySettings,
pub collaboration_settings: CollaborationSettings,
pub publication_settings: PublicationSettings,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrivacySettings {
pub visibility: ProjectVisibility,
pub data_sharing: DataSharingPolicy,
pub allow_anonymous_access: bool,
pub embargo_period_days: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ProjectVisibility {
Public,
Internal,
Private,
Restricted,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DataSharingPolicy {
Open,
OnRequest,
Restricted,
NoSharing,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollaborationSettings {
pub enable_realtime_collaboration: bool,
pub enable_version_control: bool,
pub enable_peer_review: bool,
pub enable_discussions: bool,
pub max_collaborators: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PublicationSettings {
pub default_format: PublicationFormat,
pub enable_auto_citations: bool,
pub citation_style: CitationStyle,
pub enable_preprints: bool,
pub target_venues: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum PublicationFormat {
LaTeX,
Markdown,
Html,
Pdf,
Word,
Notebook,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum CitationStyle {
APA,
IEEE,
ACM,
Nature,
Science,
Custom(String),
}
#[derive(Debug)]
pub struct ResearchProjectManager {
projects: HashMap<String, ResearchProject>,
storage_dir: PathBuf,
settings: ManagerSettings,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ManagerSettings {
pub default_template: Option<String>,
pub auto_save_frequency: u32,
pub enable_cloud_backup: bool,
pub cloud_provider: Option<String>,
pub notifications: NotificationSettings,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NotificationSettings {
pub email_enabled: bool,
pub slack_enabled: bool,
pub webhook_url: Option<String>,
pub frequency: NotificationFrequency,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum NotificationFrequency {
Realtime,
Daily,
Weekly,
Monthly,
Important,
Disabled,
}
impl ResearchProject {
pub fn new(name: &str) -> Self {
let now = Utc::now();
Self {
name: name.to_string(),
description: String::new(),
research_area: ResearchArea::MachineLearning,
status: ProjectStatus::Planning,
researchers: Vec::new(),
funding: None,
timeline: ProjectTimeline {
start_date: now,
planned_end_date: now + chrono::Duration::days(365),
actual_end_date: None,
milestones: Vec::new(),
progress_updates: Vec::new(),
},
experiments: Vec::new(),
publications: Vec::new(),
settings: ProjectSettings::default(),
created_at: now,
modified_at: now,
}
}
pub fn description(mut self, description: &str) -> Self {
self.description = description.to_string();
self.modified_at = Utc::now();
self
}
pub fn research_area(mut self, area: ResearchArea) -> Self {
self.research_area = area;
self.modified_at = Utc::now();
self
}
pub fn add_researcher(mut self, name: &str, email: &str) -> Self {
let researcher = Researcher {
name: name.to_string(),
email: email.to_string(),
affiliation: String::new(),
orcid: None,
role: ResearcherRole::Collaborator,
expertise: Vec::new(),
contact_info: ContactInfo::default(),
};
self.researchers.push(researcher);
self.modified_at = Utc::now();
self
}
pub fn funding(mut self, funding: FundingInfo) -> Self {
self.funding = Some(funding);
self.modified_at = Utc::now();
self
}
pub fn enable_reproducibility(mut self, enabled: bool) -> Self {
self.settings.enable_reproducibility = enabled;
self.modified_at = Utc::now();
self
}
pub fn add_experiment(&mut self, experiment: Experiment) -> Result<()> {
self.experiments.push(experiment);
self.modified_at = Utc::now();
Ok(())
}
pub fn add_publication(&mut self, publication: Publication) -> Result<()> {
self.publications.push(publication);
self.modified_at = Utc::now();
Ok(())
}
pub fn generate_summary_report(&self) -> String {
let mut report = String::new();
report.push_str(&format!("# {}\n\n", self.name));
report.push_str(&format!("**Description**: {}\n\n", self.description));
report.push_str(&format!("**Research Area**: {:?}\n\n", self.research_area));
report.push_str(&format!("**Status**: {:?}\n\n", self.status));
report.push_str("## Researchers\n\n");
for researcher in &self.researchers {
report.push_str(&format!(
"- {} ({}) - {:?}\n",
researcher.name, researcher.email, researcher.role
));
}
if let Some(funding) = &self.funding {
report.push_str("\n## Funding\n\n");
report.push_str(&format!("**Agency**: {}\n", funding.agency));
report.push_str(&format!("**Grant**: {}\n", funding.grant_number));
if let Some(amount) = funding.amount {
report.push_str(&format!("**Amount**: {:.2} {}\n", amount, funding.currency));
}
}
report.push_str("\n## Progress\n\n");
report.push_str(&format!("**Experiments**: {}\n", self.experiments.len()));
report.push_str(&format!("**Publications**: {}\n", self.publications.len()));
report.push_str(&format!(
"**Milestones**: {}\n",
self.timeline.milestones.len()
));
report
}
}
impl Default for ProjectSettings {
fn default() -> Self {
Self {
enable_reproducibility: true,
enable_backups: true,
backup_frequency_hours: 24,
data_retention_days: 1095, privacy_settings: PrivacySettings::default(),
collaboration_settings: CollaborationSettings::default(),
publication_settings: PublicationSettings::default(),
}
}
}
impl Default for PrivacySettings {
fn default() -> Self {
Self {
visibility: ProjectVisibility::Private,
data_sharing: DataSharingPolicy::OnRequest,
allow_anonymous_access: false,
embargo_period_days: Some(365),
}
}
}
impl Default for CollaborationSettings {
fn default() -> Self {
Self {
enable_realtime_collaboration: true,
enable_version_control: true,
enable_peer_review: true,
enable_discussions: true,
max_collaborators: Some(20),
}
}
}
impl Default for PublicationSettings {
fn default() -> Self {
Self {
default_format: PublicationFormat::LaTeX,
enable_auto_citations: true,
citation_style: CitationStyle::IEEE,
enable_preprints: true,
target_venues: Vec::new(),
}
}
}
impl ResearchProjectManager {
pub fn new(storage_dir: PathBuf) -> Result<Self> {
std::fs::create_dir_all(&storage_dir)?;
Ok(Self {
projects: HashMap::new(),
storage_dir,
settings: ManagerSettings::default(),
})
}
pub fn create_project(&mut self, name: &str) -> Result<&mut ResearchProject> {
if self.projects.contains_key(name) {
return Err(OptimError::InvalidConfig(format!(
"Project '{}' already exists",
name
)));
}
let project = ResearchProject::new(name);
self.projects.insert(name.to_string(), project);
self.save_project(name)?;
Ok(self.projects.get_mut(name).expect("unwrap failed"))
}
pub fn load_project(&mut self, name: &str) -> Result<&mut ResearchProject> {
if !self.projects.contains_key(name) {
let project_file = self.storage_dir.join(format!("{}.json", name));
if project_file.exists() {
let content = std::fs::read_to_string(&project_file)?;
let project: ResearchProject = serde_json::from_str(&content)?;
self.projects.insert(name.to_string(), project);
} else {
return Err(OptimError::InvalidConfig(format!(
"Project '{}' not found",
name
)));
}
}
Ok(self.projects.get_mut(name).expect("unwrap failed"))
}
pub fn save_project(&self, name: &str) -> Result<()> {
if let Some(project) = self.projects.get(name) {
let project_file = self.storage_dir.join(format!("{}.json", name));
let content = serde_json::to_string_pretty(project)?;
std::fs::write(&project_file, content)?;
}
Ok(())
}
pub fn list_projects(&self) -> Vec<&str> {
self.projects.keys().map(|s| s.as_str()).collect()
}
pub fn delete_project(&mut self, name: &str) -> Result<()> {
self.projects.remove(name);
let project_file = self.storage_dir.join(format!("{}.json", name));
if project_file.exists() {
std::fs::remove_file(&project_file)?;
}
Ok(())
}
}
impl Default for ManagerSettings {
fn default() -> Self {
Self {
default_template: None,
auto_save_frequency: 15, enable_cloud_backup: false,
cloud_provider: None,
notifications: NotificationSettings::default(),
}
}
}
impl Default for NotificationSettings {
fn default() -> Self {
Self {
email_enabled: true,
slack_enabled: false,
webhook_url: None,
frequency: NotificationFrequency::Daily,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile::tempdir;
#[test]
fn test_research_project_creation() {
let project = ResearchProject::new("Test Project")
.description("A test research project")
.research_area(ResearchArea::MachineLearning)
.add_researcher("Dr. Test", "test@example.com")
.enable_reproducibility(true);
assert_eq!(project.name, "Test Project");
assert_eq!(project.description, "A test research project");
assert_eq!(project.research_area, ResearchArea::MachineLearning);
assert_eq!(project.researchers.len(), 1);
assert!(project.settings.enable_reproducibility);
}
#[test]
fn test_project_manager() {
let temp_dir = tempdir().expect("unwrap failed");
let mut manager =
ResearchProjectManager::new(temp_dir.path().to_path_buf()).expect("unwrap failed");
let project = manager
.create_project("Test Project")
.expect("unwrap failed");
project.description = "Test description".to_string();
manager.save_project("Test Project").expect("unwrap failed");
let projects = manager.list_projects();
assert!(projects.contains(&"Test Project"));
manager
.delete_project("Test Project")
.expect("unwrap failed");
let projects = manager.list_projects();
assert!(!projects.contains(&"Test Project"));
}
}