BOOST--any

 
Any库概述
Any库可以改进程序:
#对任意的类型提供类型安全(typesafe)的存储和安全的检索;
#提供了在标准库容器中存放异构类型(heterogeneous type)的方法
#传递类型所通过的层无须了解任何该类型的信息.
 
Any库提供一个类型:any,它允许对任意的类型进行存储,以便稍后进行检索,而且还不损失类型的安全性.很多情况下,我们可能希望在同一个容器中存储互不相关的类型.还有很多情况下,某些特定的代码仅仅关心从一个点到另一个点传递数据的方式,而不关心数据的类型.表面上看,这些事情很容易做.它们可以通过一个诸如void *的无差别类型来实现.同样,它们还可以通过使用一个有差别的联合(discriminated union)来实现.另外,有许多变体类型都通过一些类型标记机制来实现的.然而,所有这些实现方式都缺乏类型安全性,而且只有在最可控的情形下才有可能故意绕过类型系统.标准库的容器对它们所包含的类型进行参数化,因此对这些容器中存储异构类型的元素提出了一个看上去似乎不可能实现的挑战.幸运的是,解决方案不一定必须使用void *,因为Any库允许存储不同类型的对象用于后续的检索.但是还是无法在不了解实际的情况下检索所存储的值,类型安全从而得到保证.
 
Any库的一个重要特性就是它提供了在标准容器中存储异构类型对象的能力.另外,它还是一种变体数据类型(variant data type).而这正是C++标准库非常需要但又缺乏的数据类型.
 
Any
类any 允许对任意的类型进行类型安全的存储和检索.与无差别的类型不同,any类保存了类型的信息,而且实际上还不不允许在不知道正确类型的情况下获取所存储的值.当然,若要查询类型的信息和测试所保存的值的可选项,办法还是有的.但是最终,调用者还是必须知道any对象中所存储的值的确切类型,否则any类就拒绝访问,any类来说,可以把它看作是一个上了锁的保险箱,没有匹配的钥匙,就不能进入其中.any类对它所存储的类型有以下要求:
#可复制构造(copyConstructible):它必须可以复制这个类型.
#析构函数不抛出异常:就象所有的析构函数所应该的那样的.
#可赋值(Assignable):为了保证异常安全(不符合可赋值要求的类型也可以用于any,但没有强异常安全的保证).
下面是any类的公共接口:
Namespace boost
{
 Class any {
 Public:
       Any();
       Any(const any &);
       Template<typename ValueType> any (const ValueType&);
       ~any();
       Any & swap(any &);
       Any & operator=(const any &);
       Template<type ValueType&> any & operator=(const ValueType&);
       Bool empty() const;
       Const std::type_info & type() const;
};
}
 
Any();该默认构造函数创建一个any类的空实例,即一个不含有值的any.当然,也就无法从一个空的any类中检索值,因为它里面没有值存在.
Any(const any & other);该构造函数创建一个已有的any对象的独特副本.其中other中所包含的值被复制并存储到this.
 Template<typename ValueType> any (const ValueType&);这个模板化的构造函数存储传递构造函数的类型为ValueType的参数的一份副本.其中参数是一个const引用,因此传递一个临时对象以存储到any中是合法的.注意,该构造函数不是显式的,那么any就回难以使用,而且还会影响额外的安全性.
~any();该析构函数销毁any类所包含的值,但要注意,因为裸指针(raw pointer)的析构并不会对指针调用运算符delete或运算delete[],所以在any中使用指针时,应该把裸指针包装在一个诸如shared_ptr的智能指针中.
 Any &swap(any & other);
交换两个any对象中所存储的值.
Any & operator = (const any & other);any实例是非空的,那么该函数会丢弃所存储的值,然后存入other值的一份副本.
Template<type ValueType&> any & operator=(const ValueType&);any的实例是非空的,那么该函数会丢弃所存储的值,然后存入value的一份副本,其中value可以是符合any要求的任意类型.
Bool empty() const;该函数指示当前是否包含值,但不用考虑值的类型.因此,any中存放指针时,即使该指针为空,empty函数也要返回flase.
Const std::type_info & type() const;该函数指示any对象中所存储值的类型.any对象为空,则该该函数返回的类型为void.
 
Any类中的自由函数
Template <typename ValueType> ValueType any_cast(const any& operand);
Any_cast函数允许访问any中所存储的值.其参数为要检索其中的值的any对象.如果类型ValueType与所存储的类型不符,则抛出一个类型为bad_any_cast的异常.这里需要注意的是,该函数的语法和dynamic_cast函数的语法相似.
 
Template <typename ValueType > const ValueType* any_cast(const any *operand);
Any_cast函数的重载,其参数为 any对象的指针,它返回的是一个指向所存储值的指针.any对象中的类型不是ValueType,那么该重载将返回一个空指针.注意,该重载函数的语法仍然和dynamic_cast函数的语法相似.
 
Template <typename ValueType > ValueType* any_cast(any *operand);
Any_cast函数的另一个重载,它与前一个重载版本相似,但前一个版本的参数类型和返回类型都使用了const限定的指针,而这个重载版本则不是这样的.
 
异常
 Bad_any_cast
当试图将any对象转换为该对象所存储类型以外的其他类型时,将抛出该异常.bad_any_cast异常派生自std::bad_cast.需要注意,当使用指针参数调用any_cast函数时,不会抛出异常(类似于使用指针型调用dynamic_cast函数返回空指针);但是,当使用引用类型调用any_cast函数时,则在失败时抛出异常.
 
使用用法
 Any库定义在命令空间boost.我们可以用类any来存储值,随后用模板函数any_cast来检索所存储的值.为了使用any,程序中需要包含头文件”boost/any.cpp”.创建一个可以存储任意类型的值的实例非常简单,如下所示:
Boost::any a;
对上述实例赋予某个类型的值也很容易,如下:
A = std::string(“A string”);
A = 42;
A = 3.1415;
 Any类几乎可以接受任何类型的值.但是,为了真正能使用存储在any中的值,需要检索它.为此,需要知道这个值的类型.
Std::string s = boost::any_cast<std::string> (a);
//throws boost::bad_any_cast
 上述代码不能得到正确结果,这是因为对象a中当前所包含的值是double类型的,这时any_cast将抛出一个类型为bad_any_cast的异常.但下面的代码可得到正确的结果.
Double d = boost::any_cast<double>(a);
 Any类只有在知道类型的前提下才可以访问它的值.一般要牢记:any用于存储值.而模板函数any_cast用于检索存储值.
 
现有三个类A,B,C,它们没有共同的基类,想要把它们存储到一个std::vector.(any提供了一种更好的解决方法,但是它还没有解决对类型的依赖.)
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include “boost/any.hpp”
Class A {
Public:
         Void some_function() {std::cout<<”A::somefunction()/n”;}
}
Class B {
Public:
         Void some_function() {std::cout<<”B::somefunction()/n”;}
}
Class C {
Public:
         Void some_function() {std::cout<<”C::somefunction()/n”;}
}
Int main()
{
         Std::cout<<”Example of using any./n”;
         Std::vector<boost::any> store_anything;
         Store_anything.push_back(A());
         Store_anything.push_back(B());
         Store_anything.push_back(C());
         Store_anything.push_back(std::string(“This is fantastic!”));
         Store_anything.push_back(3);
         Store_anything.push_back(std::make_apir(true,7.92));
         Void print_any(boost::any & a);
         //defined later; reports on the value in a
         Std::for_each(store_anything.begin(),store_anything.end(),print_any());
}
 
Void print_any(boost::any & a)
{
         If(A *pA = boost::any_cast<A>(&a))
         {
          pA->some_function();
}
Else if ((B*pB= boost::any_cast<B>(&a))
{
          pB->some_function();
}
Else if ((C*pC= boost::any_cast<C>(&a))
{
          pC->some_function();
}
Else
{
 Try{
 Std::cout<<boost::any_cast<std::string>(a)<<endl;
}
Catch(boost::bad_any_cast&){
 Std::cout<<”error!/n”;
}
}
}
 
(cs336) ubuntu@g1063:~/cs336$ conda install -c conda-forge cmake=3.19.6 boost boost-cpp eigen zlib libtool Channels: - conda-forge - defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: | warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE failed LibMambaUnsatisfiableError: Encountered problems while solving: - nothing provides libboost 1.71.0 haf77d95_0 needed by boost-1.71.0-py310h06a4308_0 Could not solve for environment specs The following packages are incompatible ├─ boost is installable with the potential options │ ├─ boost [1.60.0|1.61.0|...|1.67.0] would require │ │ └─ python [2.7* |>=2.7,<2.8.0a0 ], which can be installed; │ ├─ boost [1.60.0|1.61.0|1.62.0|1.63.0] would require │ │ └─ python 3.4* , which can be installed; │ ├─ boost [1.60.0|1.61.0|...|1.67.0] would require │ │ └─ python [3.5* |>=3.5,<3.6.0a0 ], which can be installed; │ ├─ boost 1.63.0 would require │ │ ├─ boost-cpp 1.63.0 , which can be installed; │ │ └─ python 2.7* , which can be installed; │ ├─ boost 1.63.0 would require │ │ ├─ boost-cpp 1.63.0 , which can be installed; │ │ └─ python 3.5* , which can be installed; │ ├─ boost 1.63.0 would require │ │ ├─ boost-cpp 1.63.0 , which can be installed; │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.63.0 would require │ │ ├─ boost-cpp 1.63.0 , which can be installed; │ │ └─ python 3.4* , which can be installed; │ ├─ boost [1.63.0|1.65.1] would require │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.64.0 would require │ │ ├─ boost-cpp 1.64.0 , which can be installed; │ │ └─ python 2.7* , which can be installed; │ ├─ boost 1.64.0 would require │ │ ├─ boost-cpp 1.64.0 , which can be installed; │ │ └─ python 3.5* , which can be installed; │ ├─ boost 1.64.0 would require │ │ ├─ boost-cpp 1.64.0 , which can be installed; │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.65.0 would require │ │ ├─ boost-cpp 1.65.0 , which can be installed; │ │ └─ python 2.7* , which can be installed; │ ├─ boost 1.65.0 would require │ │ ├─ boost-cpp 1.65.0 , which can be installed; │ │ └─ python 3.5* , which can be installed; │ ├─ boost 1.65.0 would require │ │ ├─ boost-cpp 1.65.0 , which can be installed; │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.66.0 would require │ │ ├─ boost-cpp 1.66.0 , which can be installed; │ │ └─ python 2.7* , which can be installed; │ ├─ boost 1.66.0 would require │ │ ├─ boost-cpp 1.66.0 , which can be installed; │ │ └─ python 3.5* , which can be installed; │ ├─ boost 1.66.0 would require │ │ ├─ boost-cpp 1.66.0 , which can be installed; │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.67.0 would require │ │ ├─ boost-cpp [1.67.0 |1.67.0.* ], which can be installed; │ │ └─ python [2.7* |>=2.7,<2.8.0a0 ], which can be installed; │ ├─ boost 1.67.0 would require │ │ ├─ boost-cpp [1.67.0 |1.67.0.* ], which can be installed; │ │ └─ python [3.5* |>=3.5,<3.6.0a0 ], which can be installed; │ ├─ boost 1.67.0 would require │ │ ├─ boost-cpp 1.67.0 , which can be installed; │ │ └─ python 3.6* , which can be installed; │ ├─ boost 1.67.0 would require │ │ ├─ boost-cpp 1.67.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.68.0 would require │ │ ├─ boost-cpp 1.68.0.* , which can be installed; │ │ └─ python >=2.7,<2.8.0a0 , which can be installed; │ ├─ boost 1.68.0 would require │ │ ├─ boost-cpp 1.68.0.* , which can be installed; │ │ └─ python >=3.5,<3.6.0a0 , which can be installed; │ ├─ boost 1.68.0 would require │ │ ├─ boost-cpp 1.68.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.68.0 would require │ │ ├─ boost-cpp 1.68.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.69.0 would require │ │ ├─ boost-cpp 1.69.0.* , which can be installed; │ │ └─ python >=2.7,<2.8.0a0 , which can be installed; │ ├─ boost 1.69.0 would require │ │ ├─ boost-cpp 1.69.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.69.0 would require │ │ ├─ boost-cpp 1.69.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.70.0 would require │ │ ├─ boost-cpp 1.70.0.* , which can be installed; │ │ └─ python >=2.7,<2.8.0a0 , which can be installed; │ ├─ boost 1.70.0 would require │ │ ├─ boost-cpp 1.70.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.70.0 would require │ │ ├─ boost-cpp 1.70.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.70.0 would require │ │ ├─ boost-cpp 1.70.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.71.0 would require │ │ ├─ boost-cpp 1.71.0.* , which can be installed; │ │ └─ python >=2.7,<2.8.0a0 , which can be installed; │ ├─ boost 1.71.0 would require │ │ ├─ boost-cpp 1.71.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.71.0 would require │ │ ├─ boost-cpp 1.71.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.71.0 would require │ │ ├─ boost-cpp 1.71.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.72.0 would require │ │ ├─ boost-cpp 1.72.0.* , which can be installed; │ │ └─ python >=2.7,<2.8.0a0 , which can be installed; │ ├─ boost 1.72.0 would require │ │ ├─ boost-cpp 1.72.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.72.0 would require │ │ ├─ boost-cpp 1.72.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.72.0 would require │ │ ├─ boost-cpp 1.72.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.72.0 would require │ │ ├─ boost-cpp 1.72.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.73.0 would require │ │ ├─ boost-cpp 1.73.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.73.0 would require │ │ ├─ boost-cpp 1.73.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.73.0 would require │ │ ├─ boost-cpp 1.73.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.74.0 would require │ │ ├─ boost-cpp 1.74.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.74.0 would require │ │ ├─ boost-cpp 1.74.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.74.0 would require │ │ ├─ boost-cpp 1.74.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.74.0 would require │ │ ├─ boost-cpp 1.74.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.74.0 would require │ │ ├─ boost-cpp 1.74.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.75.0 would require │ │ ├─ boost-cpp 1.75.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.75.0 would require │ │ ├─ boost-cpp 1.75.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.75.0 would require │ │ ├─ boost-cpp 1.75.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.75.0 would require │ │ ├─ boost-cpp 1.75.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.76.0 would require │ │ ├─ boost-cpp 1.76.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.76.0 would require │ │ ├─ boost-cpp 1.76.0.* , which can be installed; │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost 1.76.0 would require │ │ ├─ boost-cpp 1.76.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.76.0 would require │ │ ├─ boost-cpp 1.76.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.76.0 would require │ │ ├─ boost-cpp 1.76.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.77.0 would require │ │ ├─ boost-cpp 1.77.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.77.0 would require │ │ ├─ boost-cpp 1.77.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.77.0 would require │ │ ├─ boost-cpp 1.77.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.77.0 would require │ │ ├─ boost-cpp 1.77.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.80.0 would require │ │ ├─ boost-cpp 1.80.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.80.0 would require │ │ ├─ boost-cpp 1.80.0.* , which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.80.0 would require │ │ ├─ boost-cpp 1.80.0.* , which can be installed; │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ boost 1.80.0 would require │ │ ├─ boost-cpp 1.80.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.80.0 would require │ │ ├─ boost-cpp 1.80.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.78.0 would require │ │ ├─ boost-cpp 1.78.0.* , which can be installed; │ │ └─ python >=3.12.0rc3,<3.13.0a0 , which can be installed; │ ├─ boost [1.71.0|1.73.0|...|1.85.0] would require │ │ ├─ libboost-python-devel [1.82.0 py310h17c5347_2|1.82.0 py310h17c5347_3|...|1.85.0 py310hb7f781d_4], which requires │ │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost [1.82.0|1.83.0|1.84.0|1.85.0] would require │ │ ├─ libboost-python-devel [1.82.0 py311h781c19f_2|1.82.0 py311h781c19f_3|...|1.85.0 py311hbd00459_4], which requires │ │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost [1.71.0|1.73.0|...|1.85.0] would require │ │ ├─ libboost-python-devel [1.82.0 py39h8003fee_2|1.82.0 py39h8003fee_3|...|1.85.0 py39he8689d4_4], which requires │ │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost [1.82.0|1.83.0|1.84.0|1.85.0] would require │ │ ├─ libboost-python-devel [1.82.0 py312h8da182e_3|1.82.0 py312h8da182e_4|...|1.85.0 py312h9cebb41_4], which requires │ │ │ └─ python [>=3.12,<3.13.0a0 |>=3.12.0rc3,<3.13.0a0 ], which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost [1.71.0|1.73.0|1.82.0|1.83.0|1.85.0] would require │ │ ├─ libboost-python-devel [1.82.0 py38hb563948_2|1.82.0 py38hb563948_3|...|1.85.0 py38hb563948_4], which requires │ │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.82.0 would require │ │ ├─ boost-cpp 1.82.0.* , which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.82.0 would require │ │ ├─ boost-cpp 1.82.0.* , which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.82.0 would require │ │ ├─ boost-cpp 1.82.0.* , which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.82.0 would require │ │ ├─ boost-cpp 1.82.0.* , which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310h17c5347_0, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310h17c5347_1, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310h17c5347_2, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py313h59e1532_6, which requires │ │ └─ libboost-devel 1.84.0 h1a2810e_6, which requires │ │ ├─ boost-cpp 1.84.0* , which conflicts with any installable versions previously reported; │ │ └─ libboost 1.84.0 hb8260a3_6, which requires │ │ ├─ libzlib >=1.3.1,<2.0a0 with the potential options │ │ │ ├─ libzlib 1.3.1 would require │ │ │ │ └─ zlib 1.3.1 , which can be installed; │ │ │ ├─ libzlib 1.3.1 would require │ │ │ │ └─ zlib 1.3.1 *_1, which can be installed; │ │ │ ├─ libzlib 1.3.1 would require │ │ │ │ └─ zlib 1.3.1 *_2, which can be installed; │ │ │ └─ libzlib 1.3.1 would require │ │ │ └─ zlib 1.3.1 *_0, which can be installed; │ │ └─ zstd >=1.5.6,<1.6.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py313h59e1532_7, which requires │ │ └─ libboost-devel 1.84.0 h1a2810e_7, which requires │ │ ├─ boost-cpp 1.84.0* , which conflicts with any installable versions previously reported; │ │ └─ libboost 1.84.0 h6c02f8c_7, which requires │ │ └─ zstd >=1.5.6,<1.6.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311h781c19f_0, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311h781c19f_1, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311h781c19f_2, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39h8003fee_0|1.84.0 py39had907b7_0], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39h8003fee_1|1.84.0 py39had907b7_1], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39h8003fee_2|1.84.0 py39had907b7_2], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h8da182e_0, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h8da182e_1, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h8da182e_2, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h9cebb41_3, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h9cebb41_4, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py312h9cebb41_5, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ │ └─ python >=3.12,<3.13.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39had907b7_3|1.84.0 py39he8689d4_3], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39had907b7_4|1.84.0 py39he8689d4_4], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel [1.84.0 py39had907b7_5|1.84.0 py39he8689d4_5], which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_0, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_1, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_2, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_3, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_4, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py38hb563948_5, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310hb7f781d_3, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310hb7f781d_4, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py310hb7f781d_5, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311hbd00459_3, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311hbd00459_4, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost 1.84.0 would require │ │ └─ libboost-python-devel 1.84.0 py311hbd00459_5, which requires │ │ ├─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ ├─ boost [1.65.1|1.67.0|1.71.0|1.73.0] would require │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ boost [1.67.0|1.71.0|1.73.0] would require │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ └─ boost 1.71.0 would require │ └─ libboost 1.71.0 haf77d95_0, which does not exist (perhaps a missing channel); ├─ boost-cpp is installable with the potential options │ ├─ boost-cpp [1.65.1|1.79.0|1.81.0|1.83.0|1.85.0], which can be installed; │ ├─ boost-cpp 1.63.0, which can be installed; │ ├─ boost-cpp 1.64.0, which can be installed; │ ├─ boost-cpp 1.65.0, which can be installed; │ ├─ boost-cpp 1.66.0, which can be installed; │ ├─ boost-cpp 1.67.0, which can be installed; │ ├─ boost-cpp 1.68.0, which can be installed; │ ├─ boost-cpp 1.69.0, which can be installed; │ ├─ boost-cpp 1.70.0, which can be installed; │ ├─ boost-cpp 1.71.0, which can be installed; │ ├─ boost-cpp 1.72.0, which can be installed; │ ├─ boost-cpp 1.73.0, which can be installed; │ ├─ boost-cpp 1.74.0, which can be installed; │ ├─ boost-cpp 1.75.0, which can be installed; │ ├─ boost-cpp 1.76.0, which can be installed; │ ├─ boost-cpp 1.77.0, which can be installed; │ ├─ boost-cpp 1.78.0, which can be installed; │ ├─ boost-cpp 1.80.0, which can be installed; │ ├─ boost-cpp 1.82.0, which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ └─ libboost-devel 1.84.0 h00ab1b0_4, which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ └─ libboost-devel 1.84.0 h00ab1b0_5, which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ ├─ libboost-devel [1.84.0 h1a2810e_6|1.84.0 h1a2810e_7], which cannot be installed (as previously explained); │ │ ├─ libzlib >=1.3.1,<2.0a0 , which can be installed (as previously explained); │ │ └─ zstd >=1.5.6,<1.6.0a0 , which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ └─ libboost-devel 1.84.0 h00ab1b0_0, which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ └─ libboost-devel 1.84.0 h00ab1b0_1, which can be installed; │ ├─ boost-cpp 1.84.0 would require │ │ └─ libboost-devel 1.84.0 h00ab1b0_2, which can be installed; │ └─ boost-cpp 1.84.0 would require │ └─ libboost-devel 1.84.0 h00ab1b0_3, which can be installed; ├─ cmake 3.19.6** is not installable because there are no viable options │ ├─ cmake 3.19.6 would require │ │ └─ zstd >=1.4.5,<1.5.0a0 but there are no viable options │ │ ├─ zstd [1.4.5|1.4.8|1.4.9] would require │ │ │ └─ zlib >=1.2.11,<1.3.0a0 , which conflicts with any installable versions previously reported; │ │ └─ zstd [1.4.5|1.4.9] conflicts with any installable versions previously reported; │ └─ cmake 3.19.6 would require │ └─ zlib >=1.2.11,<1.3.0a0 , which conflicts with any installable versions previously reported; └─ pin-1 is not installable because it requires └─ python 3.13.* , which conflicts with any installable versions previously reported.
09-27
基于径向基函数神经网络RBFNN的自适应滑模控制学习(Matlab代码实现)内容概要:本文介绍了基于径向基函数神经网络(RBFNN)的自适应滑模控制方法,并提供了相应的Matlab代码实现。该方法结合了RBF神经网络的非线性逼近能力和滑模控制的强鲁棒性,用于解决复杂系统的控制问题,尤其适用于存在不确定性和外部干扰的动态系统。文中详细阐述了控制算法的设计思路、RBFNN的结构与权重更新机制、滑模面的构建以及自适应律的推导过程,并通过Matlab仿真验证了所提方法的有效性和稳定性。此外,文档还列举了大量相关的科研方向和技术应用,涵盖智能优化算法、机器学习、电力系统、路径规划等多个领域,展示了该技术的广泛应用前景。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的研究生、科研人员及工程技术人员,特别是从事智能控制、非线性系统控制及相关领域的研究人员; 使用场景及目标:①学习和掌握RBF神经网络与滑模控制相结合的自适应控制策略设计方法;②应用于电机控制、机器人轨迹跟踪、电力电子系统等存在模型不确定性或外界扰动的实际控制系统中,提升控制精度与鲁棒性; 阅读建议:建议读者结合提供的Matlab代码进行仿真实践,深入理解算法实现细节,同时可参考文中提及的相关技术方向拓展研究思路,注重理论分析与仿真验证相结合。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值