static void process( model_type &result ) { for( index_type index = 0; index < container_trait_type::size(); index ++ ) { if( result.get( index ) < bound_type::minimum( index ) ) { result.set( index, bound_type::minimum( index ) ); continue; } if( bound_type::maximum( index ) < result.get( index ) ) { result.set( index, bound_type::maximum( index ) ); continue; } } }
void operator()(model_type& model, abstract_window_type& parent) const { if (!m_confirm_file_save(parent)) return; model.reset_timetable(tetengo2::stdalt::make_unique<timetable_type>()); }
static index_type process( model_type const& m ) { for( index_type index = 0; index < container_trait_type::size(); index ++ ) { if( m.get( index ) < bound_type::minimum( index ) ) { return index; continue; } if( bound_type::maximum( index ) < m.get( index ) ) { return index; continue; } } return container_trait_type::size(); }
void L2<Model, Hessian>::hessian( const model_type &model, const double &lambda, hessian_type &hessian) { int n = model.rows(); hessian += lambda * hessian.Identity(n, n); hessian(n-1, n-1) -= lambda; }
void L2<Model, Hessian>::gradient( const model_type &model, const double &lambda, model_type &gradient) { Index i; for (i = 0; i < model.rows()-1; i++) gradient(i) += lambda * model(i); }
double L2<Model, Hessian>::loss( const model_type &model, const double &lambda) { Index i; double s = 0.; for (i = 0; i < model.rows()-1; i++) s += model(i) * model(i); return lambda * s / 2.; }
void set_message_observers( const command_set_type& command_set, diagram_view_type& diagram_view, timetable_view_type& timetable_down_view, timetable_view_type& timetable_up_view, main_window_type& main_window, const message_catalog_type& message_catalog ) { m_model.observer_set().reset().connect( model_reset_observer_type{ m_model, diagram_view, timetable_down_view, timetable_up_view, main_window } ); m_model.observer_set().changed().connect( model_changed_observer_type{ m_model, diagram_view, timetable_down_view, timetable_up_view, main_window } ); set_diagram_view_message_observers(diagram_view, main_window, message_catalog); set_timetable_view_message_observers( timetable_down_view, main_window.get_timetable_down_view_picture_box() ); set_timetable_view_message_observers(timetable_up_view, main_window.get_timetable_up_view_picture_box()); main_window.size_observer_set().resized().connect( main_window_window_resized_observer_type{ diagram_view, timetable_down_view, timetable_up_view, main_window, main_window.get_tab_frame(), main_window.get_diagram_view_picture_box(), main_window.get_timetable_down_view_picture_box(), main_window.get_timetable_up_view_picture_box(), main_window.get_property_bar() } ); main_window.file_drop_observer_set().file_dropped().connect( main_window_file_dropped_observer_type{ command_set, m_model, main_window } ); }
void execute(model_type& model, abstract_window_type& parent) const { file_property_dialog_type dialog{ parent, m_message_catalog }; dialog.set_company_name(model.timetable().company_name()); dialog.set_line_name(model.timetable().line_name()); dialog.set_note(model.timetable().note()); if (model.has_path()) dialog.set_file_name(model.path().template string<string_type>()); dialog.do_modal(); if (dialog.result() != dialog_type::result_type::accepted) return; model.timetable().set_company_name(dialog.company_name()); model.timetable().set_line_name(dialog.line_name()); model.timetable().set_note(dialog.note()); }
unsigned int decode(model_type const & model) { uint32_t const Count = GetCurrentCount(model.getTotal()); unsigned int Symbol; for(Symbol=model.getSigma()-1;model.getLow(Symbol)>Count;Symbol--) { } RemoveRange(model.getLow(Symbol),model.getHigh(Symbol),model.getTotal()); return Symbol; }
void operator()( model_type& model, const tetengo2::stdalt::optional<tetengo2::stdalt::filesystem::path>& given_path, abstract_window_type& parent) const { if (!m_ask_file_path && !model.has_path() && !given_path) return; if (!m_confirm_file_save(parent)) return; tetengo2::stdalt::filesystem::path path{}; if (given_path) { path = *given_path; } else if (m_ask_file_path) { file_open_dialog_type dialog{ m_message_catalog.get(TETENGO2_TEXT("Dialog:FileOpenSave:Open")), make_file_filters(), parent }; const auto ok = dialog.do_modal(); if (!ok) return; path = dialog.result(); } else { assert(model.has_path()); path = model.path(); } std::ifstream input_stream{ path, std::ios_base::binary }; if (!input_stream) { create_cant_open_file_message_box(path, parent)->do_modal(); return; } reader_selector_type reader_selector{ reader_set_type::create_readers( parent, path.template string<typename string_type::value_type>(), m_message_catalog) }; const auto first = tetengo2::iterator::make_observable_forward_iterator( boost::spirit::make_default_multi_pass(std::istreambuf_iterator<char>{ input_stream })); const auto last = tetengo2::iterator::make_observable_forward_iterator( boost::spirit::make_default_multi_pass(std::istreambuf_iterator<char>{})); auto error = reader_error_type::none; auto p_timetable = reader_selector.read(first, last, error); if (!p_timetable) { switch (error) { case reader_error_type::canceled: break; // Do nothing. case reader_error_type::corrupted: create_file_broken_message_box(path, parent)->do_modal(); break; case reader_error_type::unsupported: create_unsupported_format_file_message_box(path, parent)->do_modal(); break; default: assert(false); BOOST_THROW_EXCEPTION(std::logic_error("Unknown reader error.")); } return; } model.reset_timetable(std::move(p_timetable), path); }
bool reloadable( const model_type& model, const tetengo2::stdalt::optional<tetengo2::stdalt::filesystem::path>& given_path) const { return m_ask_file_path || model.has_path() || given_path; }
value_type value(std::size_t dim, State const & state, Param const & param) const { return m_model.value(dim, real_state<State const &>(*this, state), param); }
inline static void process( container_output_type & container ) { static model_type s_model{ rgb_type{ 0.69, 0.19, 0.38 } }; container = s_model.container(); }
inline static void process( container_output_type & container ) { static model_type s_model{ rgb_type{ 1, 0, 1 } }; container = s_model.container(); }
unsigned int decodeUpdate(model_type & model) { unsigned int const Symbol = decode(model); model.update(Symbol); return Symbol; }
inline static void process( container_output_type & container ) { static model_type s_model{ rgb_type{ 0xFF, 0xC0, 0xCB } }; container = s_model.container(); }
inline static void process( container_output_type & container ) { static model_type s_model{ rgb_type{ 0.5, 1, 212.0/255.0 } }; container = s_model.container(); }
inline static void process( container_output_type & container ) { static model_type s_model{ rgb_type{ 0xDC, 0x14, 0x3C } }; container = s_model.container(); }