MyToy No.1: RMI

博客介绍了银行ATM系统,每个银行有m个ATM,可进行取款、存款、查账操作,CCH负责处理跨行交易。还说明了异常情况处理,如目标银行服务器不可用时不同操作的处理方式。阐述了CCH功能及系统结构,最后给出项目编译、运行步骤和相关注意事项。

假设有n个银行,每个银行有m个ATM,每台ATM都可以withdraw自己银行的钱(废话),也可以withdraw别的银行的钱,for example,工商银行的机器也可以插交通银行的卡。总之有一个叫CCH的地方(central......house,想不起来了:)来处理这种类型的提款。另外,ATM还有deposit的功能(真先进,两机一体化),那么处理别的银行的存款时,CCH也要负责处理。当然,ATM也可以仅仅查账,看看account里还剩多少钱。一般来说,account不能为负数(不要考虑小数点之类的问题,处理整数就ok了)。CCH里每个银行对应一个银行账户,记录每个银行一共有多少存款(即这个银行所有accounts的balance总和),每当有transaction的时候要同步更新。(纯粹给人添麻烦,这种信息实际怎么会公布给银行之外的人)。不用保持高事务性,即用不着考虑类似transaction进行到一半时,目标银行或者CCH的服务器突然挂掉了这类情况。所有的account记录用简单的文件操作就ok了。

exception情况,如果request的目标银行的服务器not available怎么办?通常对withdrawal都是拒绝操作,(举例来说,你用交行的卡到工行的机器上去拿钱,交行的服务器发现工行的服务器连不上,当然就不能给你提款了,万一你丫的乘机疯狂透支怎么办,到时候工行赖帐不承认,交行非吐血不可)。但是,存款操作是可以接受的,因为对银行来说,这样的操作没有什么风险性,CCH要记录这类操作,当银行的服务器online的时候进行同步更新。(还是前面的例子,要是account是不存在的怎么办?还是那句话,对银行来说,风险是很低的)。显然,query在目标银行not available的时候是肯定reject掉的。

银行(BankI.java)提供的接口很简单:2套共6个,分别操作本行的存,取,查和远程的存取查(这里的"远程"是指对别家银行的操作)。

CCH(CCHI.java)要达到的功能:更新银行的account。帮银行transfer必要的操作,(即远程的操作),CCH要管routing。当目标银行不在线时要帮忙记录未完成的操作,当目标银行上线时提醒其更新account。(通常是远程操作,因为系统结构为ATM->BANK->CCH->REMOTE BANK。站在CCH的角度上,它要做的就是routing transaction和进行必要的update)。向银行提供接口,当银行上线时要求CCH提供未完成操作的记录来更新自己的account。

ATM只是简单的向用户收集必要的信息,然后调用相应的RMI即可,由于account不能为负,所以出错信息简单的用一系列的负数来标识。(用exception行不行,没细想,有空要try一下)

当发生远程banking操作时,本地银行把所有的信息传给CCH,CCH查看这个transaction是哪家银行的,然后把transaction传过去(实际上和TCP/IP一个道理,远程banking发生时,包含目标银行的名字,这个名字对CCH来说相当于一个Header,CCH剥掉这个Header之后再传给目标银行),站在bank的角度,这时进来的request,无论是从CCH来的还是从ATM来的,都是一样的,没有什么区别。

在CCH里有一个Map(bankname,Map(accno,amount))容器,用来记录未完成的操作,当银行上线时,先在容器里查询自己的名字,如果找到了,就说明有未完成操作需要同步更新,把相应的Map(accno,amount)拿出来逐个更新即可。

大致上整个project就是这样的了,具体查代码吧。

//ATM.java

import java.io.*;
import java.rmi.*;
import java.util.*;

public class ATM {
    String bankname;

    String accno;

    List banklist;

    public ATM() {
        bankname = new String();
        accno = new String();
        banklist = new Vector();
        banklist.add("CommonWealth");
        banklist.add("HSBC");
    }

    public static void main(String[] args) throws Exception {
        ATM myatm = new ATM();
        String str = new String();

        // stream from stdin
        BufferedReader sin = new BufferedReader(
                new InputStreamReader(System.in));

        System.out.println(myatm.banklist);
        System.out.print("Enter your Bank name(CommonWealth is default): ");
        myatm.bankname = sin.readLine();
        if (myatm.bankname.equals(""))
            myatm.bankname = (String) myatm.banklist.get(0);
        //System.out.println(myatm.bankname);

        // check if the bank name is valid
        boolean found = false;
        Iterator myit = myatm.banklist.iterator();
        while (myit.hasNext()) {
            if (myatm.bankname.equals(myit.next())) {
                found = true;
                break;
            }
        }
        if (!found) {
            System.out.println("Bank is not exist! check again!");
            System.exit(0);
        }

        // get account number:
        // a flaw here: doesnt check the validity of account
        // until transaction happens.
        System.out.print("Enter your account number: ");
        myatm.accno = sin.readLine();

        // connnect to bank server
        BankI mytransaction = (BankI) Naming.lookup("CommonWealth");
        while (true) {
            System.out.println("Welcome!/r/n" + "Press d: deposit/r/n"
                    + "Press w: withdrawal/r/n" + "Press q: query/r/n"
                    + "Press any other key to exit");

            // get transaction type
            str = sin.readLine();
            System.out.println("Please wait...");
            if (str.equals("d")) {
                // get money
                System.out.println("Input the amount of money please: ");
                int amount = Integer.decode(sin.readLine()).intValue();

                // decide which kind of RMI to be called.
                if (myatm.bankname.equals("CommonWealth"))
                    amount = mytransaction.deposit(myatm.accno, amount);
                else
                    amount = mytransaction.deposit(myatm.accno, amount,
                            myatm.bankname);

                // check the return value.
                if (amount == -999) {
                    System.out.println("account not exist!");
                    break;
                } else if (amount == -996) {
                    System.out.println("Your transaction has finished./r/n"
                            + myatm.bankname + " is not available now, you can"
                            + " deposit only.");
                    continue;
                } else if (amount == -995) {
                    System.out.println("CCH is not available now, "
                            + "you cannot do any remote transactions. "
                            + "Try later!");
                    break;
                }
                System.out
                        .println("==== Your new balance: " + amount + " ====");
            } else if (str.equals("w")) {
                System.out.println("Input the amount of money please: ");
                int amount = Integer.decode(sin.readLine()).intValue();

                // decide which kind of RMI to be called.
                if (myatm.bankname.equals("CommonWealth"))
                    amount = mytransaction.withdrawal(myatm.accno, amount);
                else
                    amount = mytransaction.withdrawal(myatm.accno, amount,
                            myatm.bankname);

                if (amount == -999) {
                    System.out.println("account not exist!");
                    break;
                } else if (amount == -998) {
                    System.out.println("insufficient funds!");
                    continue;
                } else if (amount == -997) {
                    System.out.println(myatm.bankname
                            + " is not available now! Try Later please.");
                    break;
                } else if (amount == -995) {
                    System.out.println("CCH is not available now, "
                            + "you cannot do any remote transactions. "
                            + "Try later!");
                    break;
                }
                System.out
                        .println("==== Your new balance: " + amount + " ====");
            } else if (str.equals("q")) {
                int amount;

                // decide which kind of RMI to be called.
                if (myatm.bankname.equals("CommonWealth"))
                    amount = mytransaction.query(myatm.accno);
                else
                    amount = mytransaction.query(myatm.accno, myatm.bankname);

                if (amount == -999) {
                    System.out.println("account not exist!");
                    break;
                } else if (amount == -997) {
                    System.out.println(myatm.bankname
                            + " is not available now! Try Later please.");
                    break;
                } else if (amount == -995) {
                    System.out.println("CCH is not available now, "
                            + "you cannot do any remote transactions. "
                            + "Try later!");
                    break;
                }
                System.out.println("==== Your balance: " + amount + " ====");
            } else
                break;
        }// while loop
    }
}

//BankI.java

// Bank system supplies:
// 1. two sets of RMI to ATM, one for its own banking, one for remote
//    banking.~Done.
// 2. accepting connection from CCH, which should pretend handling the
//    incoming transaction as the one from a ordinary ATM.~Done.
// 3. if CCH was down, local banking should be still working. in this
//    case, bank server should have a log system to record the change
//    of whole amount that will be used to update the bankbook in CCH
//    when it next logs on.~Done.
// here, assuming the ATM belongs to CW (Commonwealth).~Done.

import java.net.MalformedURLException;
import java.rmi.*;

public interface BankI extends Remote {

    // local banking:
    int withdrawal(String accno, int amount) throws RemoteException;

    int deposit(String accno, int amount) throws RemoteException;

    int query(String accno) throws RemoteException;

    // remote banking with an additional "bankname":
    int withdrawal(String accno, int amount, String bankname)
            throws MalformedURLException, RemoteException;

    int deposit(String accno, int amount, String bankname)
            throws MalformedURLException, RemoteException;

    int query(String accno, String bankname) throws MalformedURLException,
            RemoteException;

}///:~

// Bank.java

import java.net.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import java.io.*;

public class Bank extends UnicastRemoteObject implements BankI {

    static String datafile;

    // this variable is to log the fund of bankbook when CCH is down.
    static int pending = 0;

    static Map acc = Collections.synchronizedMap(new HashMap());

    //two things to be done in the constructor:
    //1. read acc information into Map acc.~Done
    //2. check CCH if there are any transactions unfinished.~Done.
    public Bank(String bankname) throws MalformedURLException, RemoteException {
        try {
            datafile = bankname + "accinfo.txt";
            //open data file, read everything into a Map object
            BufferedReader readacc = new BufferedReader(
                    new FileReader(datafile));
            String tmpacc;
            while ((tmpacc = readacc.readLine()) != null) {
                acc.put(tmpacc, new Integer(readacc.readLine()));
            }
            readacc.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        try {
            CCHI mycch = (CCHI) Naming.lookup("CCHserver");
            Map mymsg = mycch.check(bankname);
            if (mymsg == null)
                System.out.println("No pending transaction.");
            else {
                System.out.print("handling the pending transactions...");
                Iterator myit1 = mymsg.keySet().iterator();
                Iterator myit2 = mymsg.keySet().iterator();
                Iterator myit3 = mymsg.keySet().iterator();
                while (myit1.hasNext()) {
                    acc.put(myit1.next(), new Integer(((Integer) acc.get(myit2
                    //======^key=============================================
                            .next())).intValue()
                    //=======^original value=================================
                            + ((Integer) mymsg.get(myit3.next())).intValue()));
                    //===================^pending value======================
                }

                // write back to the file
                synchronizeDatafile(acc);
                System.out.println("finished.");
            }

        } catch (NotBoundException e) {
            // if CCH is not available, just ignore this step;
            System.out.println("CCH doesn't work.");
        }
    }

    // ========================= local banking =============================
    // return -999 means that the account is not exist.
    // return -998 means that the amount is too large.
    public int withdrawal(String accno, int amount) throws RemoteException {
        if (!acc.containsKey(accno))
            return -999;
        if (((Integer) acc.get(accno)).intValue() < amount)
            return -998;
        else {
            // update Map acc.
            acc.put(accno, new Integer(((Integer) acc.get(accno)).intValue()
                    - amount));

            // update bankbook in CCH
            try {
                CCHI myupdate = (CCHI) Naming.lookup("CCHserver");
                myupdate.update("CommonWealth", pending - amount);
                pending = 0;
            } catch (NotBoundException e) {
                pending += -amount;
            } catch (Exception e) {
                System.err.println(e);
            }

            // write back to the file
            synchronizeDatafile(acc);

            return ((Integer) acc.get(accno)).intValue();
        }
    }

    public int deposit(String accno, int amount) throws RemoteException {
        if (!acc.containsKey(accno))
            return -999;
        else {
            // update Map acc.
            acc.put(accno, new Integer(((Integer) acc.get(accno)).intValue()
                    + amount));

            // update bankbook in CCH
            try {
                CCHI myupdate = (CCHI) Naming.lookup("CCHserver");
                myupdate.update("CommonWealth", pending + amount);
                pending = 0;
            } catch (NotBoundException e) {
                pending += amount;
            } catch (Exception e) {
                System.err.println(e);
            }

            // write back to the file
            synchronizeDatafile(acc);

            return ((Integer) acc.get(accno)).intValue();
        }
    }

    public int query(String accno) throws RemoteException {
        if (!acc.containsKey(accno))
            return -999;
        else
            return ((Integer) acc.get(accno)).intValue();
    }

    // ========================= remote banking ============================
    // return -999 means that the account is not exist.
    // return -998 means that the amount is too large.
    // return -997 means that the target bank is not available.
    // return -996 means that the transaction is remote deposit.
    // return -995 means that the CCH is not working.
    public int withdrawal(String accno, int amount, String bankname)
            throws MalformedURLException, RemoteException {
        CCHI mywithdrawal;
        int tmp;
        try {
            mywithdrawal = (CCHI) Naming.lookup("CCHserver");
            tmp = mywithdrawal.withdrawal(bankname, accno, amount);
        } catch (NotBoundException e) {
            return -995;
        }

        if (tmp != -999 && tmp != -998 && tmp != -997)
            mywithdrawal.update("CommonWealth", bankname, -amount);
        return tmp;
    }

    public int deposit(String accno, int amount, String bankname)
            throws MalformedURLException, RemoteException {
        CCHI mydeposit;
        int tmp;
        try {
            mydeposit = (CCHI) Naming.lookup("CCHserver");
            tmp = mydeposit.deposit(bankname, accno, amount);
        } catch (NotBoundException e) {
            return -995;
        }
        if (tmp == -996) {
            mydeposit.update(bankname, amount);
            return -996;
        }
        if (tmp != -999)
            mydeposit.update("CommonWealth", bankname, amount);
        return tmp;
    }

    public int query(String accno, String bankname)
            throws MalformedURLException, RemoteException {
        CCHI myquery;
        try {
            myquery = (CCHI) Naming.lookup("CCHserver");
        } catch (NotBoundException e) {
            return -995;
        }
        return myquery.query(bankname, accno);
    }

    // ========================= update data file ==========================
    private void synchronizeDatafile(Map acc) {
        try {
            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(
                    datafile)));
            synchronized (acc) {
                Iterator iMap = acc.keySet().iterator();
                Iterator iMapprev = acc.keySet().iterator();
                while (iMap.hasNext()) {
                    pw.println(iMap.next());//key
                    pw.println(acc.get(iMapprev.next()));//value
                }
            }
            pw.close();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }

    // ========================= main() ====================================
    public static void main(String[] args) throws Exception {

        if (args.length < 1) {
            Bank mybank = new Bank("CommonWealth");
            Naming.rebind("CommonWealth", mybank);
            System.out.println("CommonWealth Bank ready to go");
        } else {
            Bank mybank = new Bank(args[0]);
            Naming.rebind(args[0], mybank);
            System.out.println(args[0] + " Bank ready to go");
        }
        // stream from stdin
        BufferedReader sin = new BufferedReader(
                new InputStreamReader(System.in));
        System.out.println("Type /"exit/" to shutdown the server properly.");
        // expecting "exit"
        while (!sin.readLine().equals("exit"))
            ;
        System.out.print("Exiting...");
        if (args.length < 1)
            Naming.unbind("CommonWealth");
        else
            Naming.unbind(args[0]);
        System.exit(0);
    }
}

// CCHI.java

// Central Clearing House(CCH)'s job:
// 1. maintaining account of bank which is amount of the whole funds in
//    this bank. in practice,
//     i. when local banking occurs, bank system will make request
//        through RMI to update this account of bank.~Done
//    ii. when remote banking occurs, CCH will update both bank accounts
//        involved.~Done.
// 2. routing transactions between banks. when remote banking occurs,
//    CCH will call the RMI methods which belongs to the target bank server.
//    in this case, CCH itself shoudl supply a set of RMI methods to be
//    called by the bank making request.~Done.
// 3. maintaining a log system to record unfinished deposit transaction when
//    the target bank is not available.~Done.

import java.net.*;
import java.rmi.*;
import java.util.*;

public interface CCHI extends Remote {
    // 1.i
    void update(String bankacc, int fund) throws RemoteException;

    // 1.ii
    void update(String srcbank, String dstbank, int fund)
            throws RemoteException;

    // 2.
    int withdrawal(String bankname, String accno, int amount)
            throws MalformedURLException, RemoteException;

    int deposit(String bankname, String accno, int amount)
            throws MalformedURLException, RemoteException;

    int query(String bankname, String accno) throws MalformedURLException,
            RemoteException;

    // 3.
    Map check(String bankname) throws RemoteException;
}

// CCH.java

import java.net.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import java.io.*;

public class CCH extends UnicastRemoteObject implements CCHI {

    Map book = new HashMap();

    Map bankmsg = new HashMap();

    String datafile = "bankbook.txt";

    public static void main(String[] args) throws Exception {
        CCH mycch = new CCH();

        if (args.length < 1) {
            Naming.rebind("CCHserver", mycch);
            System.out.println("CCHserver ready to go");
        } else {
            Naming.rebind(args[0], mycch);
            System.out.println(args[0] + " ready to go");
        }

        // stream from stdin
        BufferedReader sin = new BufferedReader(
                new InputStreamReader(System.in));
        System.out.println("Type /"exit/" to shutdown the server properly.");
        // expecting "exit"
        while (!sin.readLine().equals("exit"))
            ;
        System.out.print("Exiting...");
        if (args.length < 1)
            Naming.unbind("CCHserver");
        else
            Naming.unbind(args[0]);
        System.exit(0);
    }

    // similar to the bank server constructor:
    // read bank information into Map acc.~Done
    public CCH() throws RemoteException {
        try {
            //open data file, read everything into a Map object
            BufferedReader readacc = new BufferedReader(
                    new FileReader(datafile));
            String tmpacc;
            while ((tmpacc = readacc.readLine()) != null) {
                book.put(tmpacc, new Integer(readacc.readLine()));
            }
            readacc.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    public int deposit(String bankname, String accno, int amount)
            throws MalformedURLException, RemoteException {
        BankI mydeposit;
        try {
            mydeposit = (BankI) Naming.lookup(bankname);
        } catch (NotBoundException e) {
            // Map(bankname, Map(accno,amount))
            System.err.println(bankname
                    + " doesn't work. I'll handle it.from CCH.deposit");
            if (!bankmsg.containsKey(bankname)) {
                Map msg = new HashMap();
                msg.put(accno, new Integer(amount));
                bankmsg.put(bankname, msg);
            } else {
                ((HashMap) bankmsg.get(bankname)).put(accno,
                        new Integer(amount));
            }
            System.err.println("I'm returning -996. from CCH.deposit");
            return -996;
        }
        return mydeposit.deposit(accno, amount);
    }

    // return -997 means that the target bank is not available.
    public int query(String bankname, String accno)
            throws MalformedURLException, RemoteException {
        BankI myquery;
        try {
            myquery = (BankI) Naming.lookup(bankname);
        } catch (NotBoundException e) {
            System.err.println("I'm returning -997. from CCH.query");
            return -997;
        }
        return myquery.query(accno);
    }

    public void update(String bankacc, int fund) throws RemoteException {
        book.put(bankacc, new Integer(((Integer) book.get(bankacc)).intValue()
                + fund));

        // write back to the file
        try {
            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(
                    datafile)));
            Iterator iMap = book.keySet().iterator();
            Iterator iMapprev = book.keySet().iterator();
            while (iMap.hasNext()) {
                pw.println(iMap.next());//key
                pw.println(book.get(iMapprev.next()));//value
            }
            pw.close();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }

    public void update(String srcbank, String dstbank, int fund)
            throws RemoteException {
        update(srcbank, -fund);
        update(dstbank, fund);
    }

    // return -997 means that the target bank is not available.
    public int withdrawal(String bankname, String accno, int amount)
            throws MalformedURLException, RemoteException {
        BankI mywithdrawal;
        try {
            mywithdrawal = (BankI) Naming.lookup(bankname);
        } catch (NotBoundException e) {
            System.err.println("I'm returning -997. from CCH.withdrawal");
            return -997;
        }
        return mywithdrawal.withdrawal(accno, amount);
    }

    public Map check(String bankname) throws RemoteException {
        return (Map) bankmsg.remove(bankname);
    }
}

// HSBCaccinfo.txt

006
1000
005
1000
007
1000

// CommonWealthaccinfo.txt

006
1000
005
1000
007
1000

// bankbook.txt

CommonWealth
3000
HSBC
3000

// Readme.txt

There are five source files in the assignment. files with suffix 'I' means
that they are interfaces and the corresponding files are implementations.

1. Compile them following steps below.

javac CCHI.java
javac CCH.java
javac BankI.java
javac Bank.java
javac ATM.java

2. Create stubs and skeletons.

rmic CCH
rmic Bank

3. Then set up the registry.

under 32-bit Windows you say:

start rmiregistry

on unix, the command is:

rmiregistry &

4. Start.

java CCH
java Bank
(and 'java Bank HSBC' to start a remote bank)
java ATM

5. Here is some guidelines.

a) Don't run same bank server or CCH server twice. Otherwise,
   the previous one will be replaced by the new server since
   they use bank name to bind to rmiregistry.
 
b) ATM is assumed as CommonWealth's property. That is, When ATM
   prompts you to input the Bank name, you can just ENTER and don't
   need to input anything when you're trying to connect CommonWealth.
   And you cannot log on to HSBC to do local banking.

c) Basically, System won't accept negative balance, so you cannot
   withdraw money more than you have in the account.

d) Only two banks(Commonwealth & HSBC) are supported in this System now.

e) Both Commonwealth and HSBC have three accounts: 005,006,007.
   And they all have 1000 balance intially. So in CCH's bankbook,
   the intial balance of the two banks is 3000, respectively.

这个blog不能上传附件的么,帖代码多恶心

AI 代码审查Review工具 是一个旨在自动化代码审查流程的工具。它通过集成版本控制系统(如 GitHub 和 GitLab)的 Webhook,利用大型语言模型(LLM)对代码变更进行分析,并将审查意见反馈到相应的 Pull Request 或 Merge Request 中。此外,它还支持将审查结果通知到企业微信等通讯工具。 一个基于 LLM 的自动化代码审查助手。通过 GitHub/GitLab Webhook 监听 PR/MR 变更,调用 AI 分析代码,并将审查意见自动评论到 PR/MR,同时支持多种通知渠道。 主要功能 多平台支持: 集成 GitHub 和 GitLab Webhook,监听 Pull Request / Merge Request 事件。 智能审查模式: 详细审查 (/github_webhook, /gitlab_webhook): AI 对每个变更文件进行分析,旨在找出具体问题。审查意见会以结构化的形式(例如,定位到特定代码行、问题分类、严重程度、分析和建议)逐条评论到 PR/MR。AI 模型会输出 JSON 格式的分析结果,系统再将其转换为多条独立的评论。 通用审查 (/github_webhook_general, /gitlab_webhook_general): AI 对每个变更文件进行整体性分析,并为每个文件生成一个 Markdown 格式的总结性评论。 自动化流程: 自动将 AI 审查意见(详细模式下为多条,通用模式下为每个文件一条)发布到 PR/MR。 在所有文件审查完毕后,自动在 PR/MR 中发布一条总结性评论。 即便 AI 未发现任何值得报告的问题,也会发布相应的友好提示和总结评论。 异步处理审查任务,快速响应 Webhook。 通过 Redis 防止对同一 Commit 的重复审查。 灵活配置: 通过环境变量设置基
【直流微电网】径向直流微电网的状态空间建模与线性化:一种耦合DC-DC变换器状态空间平均模型的方法 (Matlab代码实现)内容概要:本文介绍了径向直流微电网的状态空间建模与线性化方法,重点提出了一种基于耦合DC-DC变换器的状态空间平均模型的建模策略。该方法通过数学建模手段对直流微电网系统进行精确的状态空间描述,并对其进行线性化处理,以便于系统稳定性分析与控制器设计。文中结合Matlab代码实现,展示了建模与仿真过程,有助于研究人员理解和复现相关技术,推动直流微电网系统的动态性能研究与工程应用。; 适合人群:具备电力电子、电力系统或自动化等相关背景,熟悉Matlab/Simulink仿真工具,从事新能源、微电网或智能电网研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握直流微电网的动态建模方法;②学习DC-DC变换器在耦合条件下的状态空间平均建模技巧;③实现系统的线性化分析并支持后续控制器设计(如电压稳定控制、功率分配等);④为科研论文撰写、项目仿真验证提供技术支持与代码参考。; 阅读建议:建议读者结合Matlab代码逐步实践建模流程,重点关注状态变量选取、平均化处理和线性化推导过程,同时可扩展应用于更复杂的直流微电网拓扑结构中,提升系统分析与设计能力。
内容概要:本文介绍了基于物PINN驱动的三维声波波动方程求解(Matlab代码实现)理信息神经网络(PINN)求解三维声波波动方程的Matlab代码实现方法,展示了如何利用PINN技术在无需大量标注数据的情况下,结合物理定律约束进行偏微分方程的数值求解。该方法将神经网络与物理方程深度融合,适用于复杂波动问题的建模与仿真,并提供了完整的Matlab实现方案,便于科研人员理解和复现。此外,文档还列举了多个相关科研方向和技术服务内容,涵盖智能优化算法、机器学习、信号处理、电力系统等多个领域,突出其在科研仿真中的广泛应用价值。; 适合人群:具备一定数学建模基础和Matlab编程能力的研究生、科研人员及工程技术人员,尤其适合从事计算物理、声学仿真、偏微分方程数值解等相关领域的研究人员; 使用场景及目标:①学习并掌握PINN在求解三维声波波动方程中的应用原理与实现方式;②拓展至其他物理系统的建模与仿真,如电磁场、热传导、流体力学等问题;③为科研项目提供可复用的代码框架和技术支持参考; 阅读建议:建议读者结合文中提供的网盘资源下载完整代码,按照目录顺序逐步学习,重点关注PINN网络结构设计、损失函数构建及物理边界条件的嵌入方法,同时可借鉴其他案例提升综合仿真能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值