Exemplo n.º 1
0
    def TestOut(self, batchtest=False):
        if not batchtest:
            print('Network Out Test Real-time')
            Batch = 1
        else:
            print('Network Out Test Batch')
            Batch = 3

        PhyTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubPhyPara)] for _ in range(Batch)],
                         dtype=torch.float)
        TOOL.ALLP(PhyTemp)
        CompTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubComPara)] for _ in range(Batch)],
                          dtype=torch.float)
        TOOL.ALLP(CompTemp)

        mu_v = self.GetPredictActorOut(x_py=PhyTemp, x_comp=CompTemp) # [3, 1]
        TOOL.ALLP(mu_v)

        mu = mu_v.data.numpy()
        logstd = self.logstd.detach().numpy()
        TOOL.ALLP(mu, 'mu')
        TOOL.ALLP(logstd, "logstd")

        action = mu + np.exp(logstd) * np.random.normal(size=logstd.shape)
        TOOL.ALLP(action, "act")
        action = mu + np.exp(logstd) * np.random.normal(size=logstd.shape)
        TOOL.ALLP(action, "act")
        action = np.clip(action, -1, 1)
        TOOL.ALLP(action, "action clip")
Exemplo n.º 2
0
    def TestOut(self, batchtest=False):
        if not batchtest:
            print('Network Out Test Real-time')
            Batch = 1
        else:
            print('Network Out Test Batch')
            Batch = 3

        PhyTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubPhyPara)] for _ in range(Batch)],
                         dtype=torch.float)
        TOOL.ALLP(PhyTemp)
        CompTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubComPara)] for _ in range(Batch)],
                          dtype=torch.float)
        TOOL.ALLP(CompTemp)

        self.GetPredictActorOut(x_py=PhyTemp, x_comp=CompTemp)
Exemplo n.º 3
0
    def TestOut(self, batchtest=False):
        if not batchtest:
            print('Network Out Test Real-time')
            Batch = 1
        else:
            print('Network Out Test Batch')
            Batch = 3

        PhyTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubPhyPara)] for _ in range(Batch)],
                         dtype=torch.float)
        TOOL.ALLP(PhyTemp)
        CompTemp = tensor([[list(random(size=self.NubTimeSeq)) for _ in range(self.NubComPara)] for _ in range(Batch)],
                          dtype=torch.float)
        TOOL.ALLP(CompTemp)

        val = self.GetPredictCrticOut(x_py=PhyTemp, x_comp=CompTemp) # [3, 1]
        TOOL.ALLP(val, "val")
        val = np.clip(val.data.numpy(), -1, 1)
        TOOL.ALLP(val, "val")
Exemplo n.º 4
0
    def get_reward(self, AMod):
        """
        R => _
        :return:
        """
        V = {
            'CNSTime': self.mem['KCNTOMS']['Val'],  # CNS Time : KCNTOMS
            'MalTime': self.mem['cMALT']['Val'],  # Mal time
            'PVCT': self.mem['PVCT']['Val'],  # VCT_pressure : PVCT
            'VCT_level': self.mem['ZVCT']['Val'],  # VCT_level : ZVCT
            'BLV616': self.mem['BLV616']['Val'],  # LV616_pos : BLV616
            'KLAMPO71': self.mem['KLAMPO71']['Val'],  # CHP1 : KLAMPO71
            'KLAMPO72': self.mem['KLAMPO72']['Val'],  # CHP2 : KLAMPO72
            'KLAMPO73': self.mem['KLAMPO73']['Val'],  # CHP2 : KLAMPO73
            'WCMINI': self.mem['WCMINI']['Val'],  # Mini Flow : WCMINI
            'BHV30': self.mem['BHV30']['Val'],  # HV30_pos : BHV30
            'BHV50': self.mem['BHV50']['Val'],  # HV50_pos : BHV50
            'BFV122': self.mem['BFV122']['Val'],  # FV122_pos : BFV122
            'WAUXSP': self.mem['WAUXSP']['Val'],  # AuxSpray_Flow : WAUXSP
            'BHV40': self.mem['BHV40']['Val'],  # HV40 : BHV40
            'WNETCH': self.mem['WNETCH']['Val'],  # Total_Charging_Flow: WNETCH
            'URHXUT': self.mem['URHXUT']['Val'],  # Letdown_temp : URHXUT
            'UCHGUT': self.mem['UCHGUT']['Val'],  # Charging_temp : UCHGUT
            'ZINST58': self.mem['ZINST58']['Val'],  # PZR_press : ZINST58
            'PZR_level': self.mem['ZINST63']['Val'],  # PZR_level : ZINST63
            'BLV459': self.mem['BLV459']['Val'],  # Letdown_pos : BLV459
            'BHV1': self.mem['BHV1']['Val'],  # Orifice_1 : BHV1
            'BHV2': self.mem['BHV2']['Val'],  # Orifice_2 : BHV2
            'BHV3': self.mem['BHV3']['Val'],  # Orifice_3 : BHV3
            'BPV145': self.mem['BPV145']['Val'],  # Letdown_HX_pos : BPV145
            'ZINST36':
            self.mem['ZINST36']['Val'],  # Letdown HX Press : ZINST36
            'BHV41': self.mem['BHV41']['Val'],  # HV41_pos : BHV41
            'KHV43': self.mem['KHV43']['Val'],  # HV43_pos : KHV43
            'WEXLD': self.mem['WEXLD']['Val'],  # VCT_flow : WEXLD
            'WDEMI': self.mem['WDEMI']['Val'],  # Total_in_VCT : WDEMI
        }
        PZR_level_set = 57
        VCT_level_set = 74

        r = [0, 0]
        r[0] = TOOL.generate_r(curr=V['PZR_level'],
                               setpoint=PZR_level_set,
                               distance=0.5,
                               max_r=0.5,
                               min_r=-5)
        r[1] = V['CNSTime'] / 50  # [1~500] 값 생산
        r[1] = r[1] / 250  #[1/250 ~ 2]
        self.Loger_txt += f'R:,{r},\t'
        r = sum(r) / 100
        # r = self.normalize(sum(r), 0, -5, 0.5) / 10
        self.AcumulatedReward += r
        return r