You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def _evaluate(self, x):
print("HI")
edge_ordering = np.argsort(x)+1
result = logcontract(deepcopy(graph), bdims, edge_ordering)
if result is None:
result = np.inf
return result
1 frames /usr/local/lib/python3.9/dist-packages/niapy/task.py in init(self, problem, dimension, lower, upper, optimization_type, repair_function, max_evals, max_iters, cutoff_value, enable_logging)
83 logger.warning('An instance of the Problem class was passed in, dimension, lower and upper parameters will be ignored.')
84 else:
---> 85 raise TypeError('Unsupported type for problem: {}'.format(type(problem)))
86
87 self.optimization_type = optimization_type
TypeError: Unsupported type for problem: <class 'NoneType'>. Initializing ContractCostTask... is printed but HI is not printed, which means the _evaluate function is not being called atleast once. Please help me find what I'm missing here.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey Everyone, I am new to using this library and I am currently struck with the following error in my code.
class ContractCostTask(Task):
def init(self, graph, bdims, num_bonds):
print("Initializing ContractCostTask...")
super().init(dimension=num_bonds)
self.graph=graph
self.bdims=bdims
self.num_bonds=num_bonds
task = ContractCostTask(graph, bdims, num_bonds)
algorithm = ParticleSwarmAlgorithm(population_size=20, c1=1.5, c2=2.0, w=0.7, max_evals=num_greedy)
best_solution = algorithm.run(task)
print(best_solution).
TypeError Traceback (most recent call last)
in
18 print(bdims)
19 print(num_bonds)
---> 20 task = ContractCostTask(graph, bdims, num_bonds)
21 algorithm = ParticleSwarmAlgorithm(population_size=20, c1=1.5, c2=2.0, w=0.7, max_evals=num_greedy)
22 best_solution = algorithm.run(task)
1 frames
/usr/local/lib/python3.9/dist-packages/niapy/task.py in init(self, problem, dimension, lower, upper, optimization_type, repair_function, max_evals, max_iters, cutoff_value, enable_logging)
83 logger.warning('An instance of the Problem class was passed in,
dimension
,lower
andupper
parameters will be ignored.')84 else:
---> 85 raise TypeError('Unsupported type for problem: {}'.format(type(problem)))
86
87 self.optimization_type = optimization_type
TypeError: Unsupported type for problem: <class 'NoneType'>. Initializing ContractCostTask... is printed but HI is not printed, which means the _evaluate function is not being called atleast once. Please help me find what I'm missing here.
Beta Was this translation helpful? Give feedback.
All reactions