我正忙于我的最后一年项目的计划。下面的方法需要返回一个组合列表,一个组合就是一个LoadCases列表(variableLoad和permanentLoad是LoadCase的子类):
public ArrayList<ArrayList<LoadCase>> strUfCombinations()
{
ArrayList<ArrayList<LoadCase>> combinationslist = new ArrayList<ArrayList<LoadCase>>();
int i = 0;
for(int x = 0; x < allvariableLoads.size(); x++)
{
combinationslist.add(new ArrayList<LoadCase>());
}
ListIterator<ArrayList<LoadCase>> cListItr = combinationslist.listIterator();
while(cListItr.hasNext())
{
cListItr.next();
ArrayList<LoadCase> combination = new ArrayList<LoadCase>();
for(int j = 0; j < allvariableLoads.size(); j++)
{
allvariableLoads.get(j).setIsLeading(false);
}
allvariableLoads.get(i).setIsLeading(true);
Iterator<VariableLoad> vLoadIterator = allvariableLoads.iterator();
while(vLoadIterator.hasNext())
{
VariableLoad vload = vLoadIterator.next();
if(vload.getIsLeading()==true)
{
vload.finalfactor = vload.partialFactor.strUf;
}
if(vload.getIsLeading()== false)
{
vload.finalfactor = vload.combinationFactor * vload.partialFactor.strUf;
}
combination.add(vload);
}
Iterator<PermanentLoad> pLoadIterator = permanentLoads.iterator();
while(pLoadIterator.hasNext())
{
PermanentLoad pload = pLoadIterator.next();
pload.finalfactor = pload.partialFactor.strUf;
combination.add(pload);
}
Iterator<LoadCase> combItr = combination.iterator();
while(combItr.hasNext())
{
LoadCase test = combItr.next();
System.out.print(test.finalfactor+test.name+" ");
}
System.out.println();
cListItr.set(combination);
i++;
}
System.out.println("\n");
return combinationslist;
}
我正在使用一个测试类来运行它:
public static void main(String[] args)
{
PermanentLoad testload = new PermanentLoad("DL1", "self");
PermanentLoad testload2 = new PermanentLoad("DL2", "geofac");
PermanentLoad testload3 = new PermanentLoad("DL3", "fluid");
PermanentLoad testload4 = new PermanentLoad("DL4", "geounf");
VariableLoad vload1 = new VariableLoad("VL1", "imposed", "A");
VariableLoad vload2 = new VariableLoad("VL2", "wind", "normal");
VariableLoad vload3 = new VariableLoad("VL3", "imposed", "E2");
VariableLoad vload4 = new VariableLoad("VL4", "thermal", "normal");
CasesManager manager = new CasesManager();
manager.addCase("DL1", "self", "null");
manager.addCase("DL2", "geofac", "null");
manager.addCase("DL3", "fluid", "null");
manager.addCase("DL4", "geounf", "null");
manager.addCase("VL1", "imposed", "A");
manager.addCase("VL2", "wind", "normal");
manager.addCase("VL3", "imposed", "E2");
manager.addCase("VL4", "thermal", "normal");
manager.addCase("VL5", "cranes", "normal");
System.out.println("\n");
CombinationCalculator calc = new CombinationCalculator(manager);
ArrayList<ArrayList<LoadCase>> combinations = calc.strUfCombinations();
Iterator<ArrayList<LoadCase>> cListItr = combinations.iterator();
while(cListItr.hasNext())
{
Iterator<LoadCase> combItr = cListItr.next().iterator();
while(combItr.hasNext())
{
LoadCase test = combItr.next();
System.out.print(test.finalfactor+test.name+" ");
}
System.out.println();
}
我运行测试类时的输出是:
1.6VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 1.6VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 1.6VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 1.3VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
0.48VL1 0.96VL3 0.48VL4 0.0VL2 1.6VL5 1.2DL1 0.0DL2 1.2DL3 1.2DL4
该矩阵是从 strUfCombinations() 中打印的,第二个矩阵是通过迭代最终的组合列表从测试类打印的。第一个矩阵是正确的输出。在我看来, strUfCombinations() 方法正在使用添加的最后一个组合填充组合列表。
任何人都可以帮忙吗?也许我只是缺少一些简单的东西。
问候, 雅克