我将尝试在sympy中使用solve函数的结果
public class Building {
private int xSize = 10;
private int ySize = 10; // and y
private ArrayList<Room> allRooms;
private Person P;
Building (String first){
allRooms = new ArrayList<Room>();
setBuilding(first);
}
public void setBuilding(String bS) {
String[] Space;
allRooms.clear();
Space = bS.split(";");
//defining the x and y coordinate
String[] buildingSize = Space[0].split(" ");
xSize = Integer.parseInt(buildingSize[0]);
ySize =Integer.parseInt(buildingSize[1]);
allRooms.add(new Room(Space[1]));
allRooms.add(new Room(Space[2]));
allRooms.add(new Room(Space[3]));
Person P = new Person (new Point(2,3));
}
public String toString() {
String s = "Building size " + xSize +","+ySize + P + '\n';
for (Room r : allRooms) { //for loop
s += r.toString();
}
return s;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Building b = new Building("11 11;0 0 5 5 3 5;6 0 10 10 6 6;0 5 5 10 2 5"); // create
System.out.println(b.toString()); // and print
}
结果是
from sympy import solve, expand,
SolutionForPi = (alpha*mu*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(-rho/(rho - 1) + 1) + f*mu)-pi
SolutionForPi = solve(SolutionForPi, pi)
然后我使用sympy.expend函数
[mu*(-alpha*gamma*l*rho**2 + 2*alpha*gamma*l*rho - alpha*gamma*l - alpha*l*rho**2 + alpha*l*rho - f)/(alpha*gamma*mu*rho**2 - 2*alpha*gamma*mu*rho + alpha*gamma*mu + alpha*mu*rho**2 - alpha*mu*rho - 1)]
但是我得到这个错误:
ExpandSolution = expand(SolutionForPi)
我了解这是列表而不是等式,所以我该怎么办?
答案 0 :(得分:1)
如果您的解决方案封装在列表中,请访问(单个)列表成员
ExpandSolution = expand(SolutionForPi[0])