weixin_39541121
weixin_39541121
2020-12-25 19:10

shark::Individual should implement shark::ISerializable

The Individual class in Algorithms/DirectSearch/Individual.h does not inherit from shark::ISerializable. This appears to be a mistake, as shark::Individual does implement a serialization call.

该提问来源于开源项目:Shark-ML/Shark

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39860849 weixin_39860849 4月前

    This is not a problem, as boost serialization does not require the use of a base class. The only thing this allows is the (de)serialization of abstract base-classes when the classes themself are not registered to the serializer (i.e. the user keeps track of the types). This is required in cases where we use type-erasures (e.g. ConcenatedModel). The individual classes are not one of these cases.

    点赞 评论 复制链接分享
  • weixin_39541121 weixin_39541121 4月前

    But wouldn't it be prettier if it declared that it was serializable, seeing as it is so? It would make it simpler for users to write something takes takes "anything that Shark knows how to serialize", e.g.

    点赞 评论 复制链接分享
  • weixin_39860849 weixin_39860849 4月前

    This approach has the disadvantage as the ISerializable interface only works with polymorphic archives, while the "normal" boost serializable interface always works. Are you stumbling over this problem right now?

    点赞 评论 复制链接分享
  • weixin_39541121 weixin_39541121 4月前

    Okay, fair enough. I did run into it, but it's not overly difficult to handle. I just thought it would make sense for a class to "broadcast" that it can be serialized.

    点赞 评论 复制链接分享

相关推荐