/** * Constructs the root node in the solution space of a * this scales balancing problem. */ public function __construct(ScalesBalancingProblem $problem) { parent::__construct(); $this->problem = $problem; $this->diff = 0; $this->unplacedTotal = 0; $this->numberPlaced = 0; $this->pan = new BasicArray($this->problem->getNumberOfWeights()); $weights = $this->problem->getWeights(); for ($i = 0; $i < $this->problem->getNumberOfWeights(); ++$i) { $this->unplacedTotal += $weights[$i]; } }
/** * Constructs the root node in the solution space of a * this 0/1 knapsack problem. */ public function __construct(ZeroOneKnapsackProblem $problem) { parent::__construct(); $this->problem = $problem; $this->totalWeight = 0; $this->totalProfit = 0; $this->unplacedProfit = 0; $this->numberPlaced = 0; $this->x = new BasicArray($this->problem->getNumberOfItems()); $profit = $this->problem->getProfit(); for ($i = 0; $i < $this->problem->getNumberOfItems(); ++$i) { $this->unplacedProfit += $profit[$i]; } }