首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏CreateAMind

    State Abstraction as 压缩 in Apprenticeship Learning

    code: State Abstraction as Compression in Apprenticeship Learning https://github.com/david-abel/rl_info_theory for Lifelong Reinforcement Learnin https://david-abel.github.io/papers/lifelong_sa_icml_18.pdf State Abstraction Abstract State abstraction can give rise to models of environments that are both compressed and useful We illustrate the power of this algorithmic structure to offer insights into ef- fective abstraction, One path toward realizing this goal is to make use of state abstraction, which describes methods for

    48441发布于 2019-04-28
  • 来自专栏CreateAMind

    A Theory of State Abstraction for Reinforcement Learning

    A Theory of State Abstraction for Reinforcement Learning David Abel Department of Computer Science Brown Abstraction is essential to all of these endeavors. Through abstraction, agents can form concise models of both their surroundings and behavior, supporting learning, with a focus on state abstraction. Abstraction is essential to all of these endeavors: through abstraction, agents can construct models

    49610发布于 2019-04-28
  • 来自专栏iOS 开发

    iOS 代码使用 C++ 的 zero-cost abstraction 特性

    上超过 150 MB 的 App 只能通过 Wifi 下载,当常规的瘦身手段用尽之后,App size 每一个 MB 的减少都弥足珍贵,这篇文章向 iOS 开发者介绍 C++ 的 zero cost abstraction zero-cost abstraction Objective-C 和 C++ 同为面向对象语言,我们通过对象来抽象世界中的概念,但 Objective-C 的抽象伴随着代价,抽象越多,定义的类越多,最后编译出的 通过上面的分析我们也不难发现 zero-cost abstraction 的好处体现在两方面,一是 binary 更小,二是运行时更高效(没有一层层的中转)。

    99930发布于 2018-06-05
  • 来自专栏C/C++进阶专栏

    C++设计模式——Bridge桥接模式

    2.RefinedAbstraction:扩充抽象类,有的教程里面称为"ExtendedAbstraction",Abstraction的子类,扩充Abstraction的抽象接口。 _1 = new ConcreteImplementationA; Abstraction* abstraction_1 = new Abstraction(implementation_1); abstraction_1; Implementation* implementation_2 = new ConcreteImplementationB; Abstraction* abstraction_2 = new RefinedAbstraction(implementation_2); ClientCode(*abstraction_2); delete implementation_2; delete abstraction_2; return 0; } 运行结果: Abstraction: Base operation with

    65410编辑于 2024-06-18
  • 来自专栏挖坑填坑

    设计模式- 桥接模式(Bridge Pattern)

    abstraction = new AbstractionRefined(); abstraction. _implementor = new ImplementorA(); abstraction.Operation(); abstraction. RefinedAbstraction:扩充由Abstraction定义的接口; Implementor:定义实现类的接口,该接口不一定要与Abstraction的接口完全一致,事实上两个接口可以完全不同 Abstraction类和Client类。 系统的高层部分仅需要知道Abstraction和Implementor即可; 提高可扩充性。可以独立的对Abstraction和Implementor层次结构进行扩充; 实现细节对Client透明。

    70520发布于 2019-05-10
  • 来自专栏JAVA乐园

    桥接模式

    主要角色如下: Implementor:实现化角色,它是接口或者抽象类,定义角色必需的行为和属性;这个接口不一定要与Abstraction的接口完全一致,事实上这两个接口可以完全不同,一般而言,Implementor 接口仅提供基本操作,而Abstraction定义的接口可能会做更多更复杂的操作。 在不同的ConcreteImplementor中提供基本操作的不同实现,在程序运行时,ConcreteImplementor对象将替换其父类对象,提供给抽象类具体的业务操作方法; Abstraction abstraction1 = new RefinedAbstraction(Implementor1); abstraction1.request(); Implementor implementor2 = new ConcreteImplementorB(); Abstraction abstraction2 = new RefinedAbstraction

    1.7K30发布于 2021-01-18
  • 来自专栏CodeTime

    桥接模式(Bridge)

    结构 抽象部分(Abstraction)提供高层控制逻辑,依赖于完成底层实际工作的实现对象。 实现部分(Implementation)为所有具体实现声明通用接口。 class Abstraction { protected IImplementation _implementation; public Abstraction public void ClientCode(Abstraction abstraction) { Console.Write(abstraction.Operation // abstraction-implementation combination. abstraction = new Abstraction(new ConcreteImplementationA()); client.ClientCode(abstraction

    1.2K20编辑于 2023-03-08
  • 来自专栏Reck Zhang

    Design Patterns 22 - 桥接模式

    ConcreteImplementorB : Implementor { public override void Operation() { // todo } } class Abstraction public virtual void Operation() { implementor.Operation(); } } class RefinedAbstraction : Abstraction Operation() { implementor.Operation(); } } public static void Main(string[] agrs) { Abstraction abstraction = new RefinedAbstraction(); abstraction.SetImplementor(new ConcreteImplementorA()); abstraction.Operation(); abstraction.SetImplementor(new ConcreteImplementorB()); abstraction.Operation

    47430发布于 2021-08-11
  • 来自专栏Lvshen的技术小屋

    设计模式23之桥接模式(终章)

    什么是桥接模式 “Decouple an abstraction from its implementation so that the two can vary independently. 桥接模式主要组成结构: 抽象化(Abstraction)角色:定义抽象类,并包含一个对实现化对象的引用。 扩展抽象化(Refined Abstraction)角色:是抽象化角色的子类,实现父类中的业务方法,并通过组合关系调用实现化角色中的业务方法。 public abstract class Abstraction { protected Implementor implementor; public Abstraction(Implementor public abstract void operation(); } RefinedAbstraction public class RefinedAbstraction extends Abstraction

    38510编辑于 2022-05-05
  • 来自专栏嵌入式开发圈

    C++ 桥接模式 - 开关和电器

    Abstraction(抽象类):用于定义抽象类的接口,并且维护一个指向 Implementor 实现类的指针。它与 Implementor 之间具有关联关系。 Implementor(实现类接口):定义实现类的接口,这个接口不一定要与 Abstraction 的接口完全一致,事实上这两个接口可以完全不同。 在程序运行时,ConcreteImplementor 对象将替换其父类对象,提供给 Abstraction 具体的业务操作方法。 2 优缺点 优点: 分离抽象和实现部分。 也就是说,每个 ISwitch 应该持有一个 IEquipment 对象: // abstraction.h #ifndef ABSTRACTION_H #define ABSTRACTION_H # 创建扩充抽象类 特定类型的开关很多,比如拉链式开关、两位开关: // refined_abstraction.h #ifndef REFINED_ABSTRACTION_H #define REFINED_ABSTRACTION_H

    83620发布于 2021-03-15
  • 来自专栏喵叔's 专栏

    【地铁上的设计模式】--结构型模式:桥接模式

    { protected IImplementor implementor; public Abstraction(IImplementor implementor) { abstraction = new RefinedAbstractionA(new ConcreteImplementorA()); abstraction.Operation(); ()); abstraction.Operation(); // 使用ConcreteImplementorC实现 abstraction = new RefinedAbstractionA(new ConcreteImplementorC()); abstraction.Operation(); Console.ReadKey 和ConcreteImplementorC分别是三个具体的实现类,RefinedAbstractionA和RefinedAbstractionB是两个扩展抽象类,通过继承Abstraction来对抽象类进行扩展

    45040编辑于 2023-05-03
  • 来自专栏静默虚空的博客

    JAVA 设计模式 桥接模式

    interface Implementor { // 实现抽象部分需要的某些具体功能 public void operationImpl(); } Abstraction : 定义抽象接口。 abstract class Abstraction { // 持有一个 Implementor 对象,形成聚合关系 protected Implementor implementor; public  Abstraction(Implementor implementor) { this.implementor = implementor;     } // 可能需要转调实现部分的具体实现  中定义的方法, // 通过组合使用 Abstraction 中定义的方法来完成更多的功能。       = new RefinedAbstraction(implementor);         abstraction.operation();         abstraction.otherOperation

    1K100发布于 2018-01-05
  • 来自专栏xingoo, 一个梦想做发明家的程序员

    【设计模式】—— 桥接模式Bridge

    模式结构 Abstraction 抽象部分的基类,定义抽象部分的基础内容。 RefinedAbstraction 抽象部分的扩充,用于对基类的内容补充,添加特定场景的业务操作。   代码结构 1 package com.xingoo.test; 2 /** 3 * 抽象类基类 4 * @author xingoo 5 */ 6 abstract class Abstraction 44 public class test { 45 public static void main(String[] args){ 46 RefinedAbstraction abstraction = new RefinedAbstraction(); 47 abstraction.operation(new ConcreteImplementorA()); 48 49 abstraction.operation(new ConcreteImplementorB()); 50 } 51 } 52 运行结果 ConcreteImplementorA

    70270发布于 2018-01-18
  • 来自专栏运维开发王义杰

    设计模式:桥接模式的解析与Go语言实现

    桥接模式的结构 桥接模式通常包含以下几个组成部分: 抽象类(Abstraction):定义抽象类的接口。 扩展抽象类(Refined Abstraction):扩展由抽象类定义的接口。 ConcreteImplementorB) OperationImpl() string { return "ConcreteImplementorB Operation" } // 抽象类 type Abstraction struct { imp Implementor } func (a *Abstraction) Operation() string { return a.imp.OperationImpl {} abstractionA := RefinedAbstraction{Abstraction{implementorA}} fmt.Println(abstractionA.Operation ()) implementorB := &ConcreteImplementorB{} abstractionB := RefinedAbstraction{Abstraction{implementorB

    36130编辑于 2023-11-20
  • 来自专栏营琪的小记录

    复习:GoF的23种设计模式之Bridge模式(结构型)

    正确示例代码: public class BridgeTest { public static void main(String[] args) { Abstraction coldAbstraction = new Abstraction(new ColdWaterImplementor()); coldAbstraction.use(); System.out.println hotAbstraction = new Abstraction(new HotWaterImplementor()); hotAbstraction.use(); } } class Abstraction{ //当作一个抽象化的水龙头 //功能层次顶部 private Implementor impl; public Abstraction(Implementor public void use() { impl.open(); impl.close(); } } class FunctionAbstraction extends Abstraction

    44010发布于 2019-12-25
  • 来自专栏cwl_Java

    设计模式-桥接模式

    * @date : 2019/6/24 10:50 */ void OperationImpl(); } 2.2 抽象化角色 public abstract class Abstraction { protected Implementor imple; protected Abstraction(Implementor imple) { this.imple ; } public abstract void Operation(); } 2.3 拓展抽象化角色 public class RefinedAbstraction extends Abstraction imple); } @Override public void Operation() { System.out.println("扩展抽象化(Refined Abstraction public static void main(String[] args) { Implementor imple=new ConcreteImplementorA(); Abstraction

    76710发布于 2019-10-26
  • 来自专栏Golang语言社区

    Golang语言情怀-第20期 Go 语言设计模式-桥接

    –定义实现类的接口,该接口不一定要与abstraction的接口完全一致;事实上这两个接口也可以完全不同。 一般来讲,implementor接口仅提供基本操作,而abstraction定义了基于这些操作的较高层次的操作。 将abstraction与Implementor分离有助于降低对实现部分编译时刻的依赖性,当改变一个实现类时,不需要重新编译abstraction类和客户重新。 另外,接口和实现分离有助于分层,从而产生更好的结构化系统,系统的高层部分只要知道abstraction和implementor即可。 2)提高可扩展性,可以独立对Abstraction和Implementor层次进行扩展。 3)实现细节对可对客户透明。 缺点: 不容易设计,需不需要分离,如何分离等问题。比较难以拿捏。

    60010发布于 2021-02-05
  • 来自专栏码匠的流水账

    聊聊软件开发的SLAP原则

    序 本文主要研究一下软件开发的SLAP(Single Level of Abstraction Principle)原则 SLAP SALP即Single Level of Abstraction Principle 另外没有循序这个原则的通常是Leaky Abstraction 要遵循这个原则通常有两个好用的手段便是抽取方法与抽取类。 另外没有循序这个原则的通常是Leaky Abstraction。 Level of Abstraction (SLA) The Single Level of Abstraction Principle SLAP Your Methods and Don't Make Levels of Abstraction Maintain a Single Layer of Abstraction at a Time | Object-Oriented Design Principles

    56440编辑于 2022-04-05
  • 来自专栏三流程序员的挣扎

    2022-10-11-桥梁模式

    Implementor{ public void doSomething(){} public void doAnything(){} } public abstract class Abstraction { //定义对实现化角色的引用 private Implementor imp; //约束子类必须实现该构造函数 public Abstraction(Implementor public Implementor getImp(){ return imp; } } public class RefinedAbstraction extends Abstraction public class Client { public static void main(String[] args) { // 要修改,用不同的 Implementor,Abstraction 实现 // 两者在接口中已经定义好了逻辑关系 Implementor imp = new ConcreteImplementor1(); Abstraction

    32940编辑于 2022-10-25
  • 来自专栏Python机器学习算法说书人

    Python设计模式(9):桥接模式

    Abstraction 接口:定义抽象部分的接口,维持 Implementor 对象的一个参考(Reference)。 RefindedAbstraction 类:是一个实类,继承或者实现 Abstraction。 ,Abstraction 接口通常提供比较高级的功能。 甚至 Abstraction 的具体实现类 RefinedAbstraction 改变了,客户程序都不必重新编译。 桥接模式有如下优点。 分离接口和实现部分。一个实现不必固定地绑定一个接口。 = eval(f'RefinedAbstraction{abstract}(implementor)') abstraction.operation() if __name__ =

    74830发布于 2019-07-26
领券