Skip to content

Commit 9cb0a4a

Browse files
committed
minor changes to the examples/region_optimal.ipynb and _gqr
1 parent f71f77d commit 9cb0a4a

File tree

3 files changed

+457
-57
lines changed

3 files changed

+457
-57
lines changed

examples/cost_constrained_qr.ipynb

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@
334334
}
335335
],
336336
"metadata": {
337+
"hide_input": false,
337338
"kernelspec": {
338-
"display_name": "Python 3",
339+
"display_name": "Python 3 (ipykernel)",
339340
"language": "python",
340341
"name": "python3"
341342
},
@@ -349,7 +350,35 @@
349350
"name": "python",
350351
"nbconvert_exporter": "python",
351352
"pygments_lexer": "ipython3",
352-
"version": "3.6.9"
353+
"version": "3.9.5"
354+
},
355+
"latex_envs": {
356+
"LaTeX_envs_menu_present": true,
357+
"autoclose": false,
358+
"autocomplete": true,
359+
"bibliofile": "biblio.bib",
360+
"cite_by": "apalike",
361+
"current_citInitial": 1,
362+
"eqLabelWithNumbers": true,
363+
"eqNumInitial": 1,
364+
"hotkeys": {
365+
"equation": "Ctrl-E",
366+
"itemize": "Ctrl-I"
367+
},
368+
"labels_anchors": false,
369+
"latex_user_defs": false,
370+
"report_style_numbering": false,
371+
"user_envs_cfg": false
372+
},
373+
"nbTranslate": {
374+
"displayLangs": [
375+
"*"
376+
],
377+
"hotkey": "alt-t",
378+
"langInMainMenu": true,
379+
"sourceLang": "en",
380+
"targetLang": "fr",
381+
"useGoogleTranslate": true
353382
},
354383
"toc": {
355384
"base_numbering": 1,
@@ -363,6 +392,35 @@
363392
"toc_position": {},
364393
"toc_section_display": true,
365394
"toc_window_display": false
395+
},
396+
"varInspector": {
397+
"cols": {
398+
"lenName": 16,
399+
"lenType": 16,
400+
"lenVar": 40
401+
},
402+
"kernels_config": {
403+
"python": {
404+
"delete_cmd_postfix": "",
405+
"delete_cmd_prefix": "del ",
406+
"library": "var_list.py",
407+
"varRefreshCmd": "print(var_dic_list())"
408+
},
409+
"r": {
410+
"delete_cmd_postfix": ") ",
411+
"delete_cmd_prefix": "rm(",
412+
"library": "var_list.r",
413+
"varRefreshCmd": "cat(var_dic_list()) "
414+
}
415+
},
416+
"types_to_exclude": [
417+
"module",
418+
"function",
419+
"builtin_function_or_method",
420+
"instance",
421+
"_Feature"
422+
],
423+
"window_display": false
366424
}
367425
},
368426
"nbformat": 4,

examples/region_optimal.ipynb

Lines changed: 390 additions & 47 deletions
Large diffs are not rendered by default.

pysensors/optimizers/_gqr.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self,idx_constrained,n_sensors,const_sensors,all_sensors):
3535
Ranked list of sensor locations.
3636
idx_constrained : np.ndarray, shape [No. of constrained locations]
3737
Column Indices of the sensors in the constrained locations.
38-
n_sensors : integer,
38+
n_sensors : integer,
3939
Total number of sensors
4040
const_sensors : integer,
4141
Total number of sensors required by the user in the constrained region.
@@ -88,7 +88,7 @@ def fit(
8888

8989
# Choose pivot
9090
i_piv = np.argmax(dlens_updated)
91-
91+
9292
dlen = dlens_updated[i_piv]
9393

9494
if dlen > 0:
@@ -174,7 +174,7 @@ def getConstraindSensorsIndices(xmin, xmax, ymin, ymax, nx, ny, all_sensors):
174174
175175
Parameters
176176
----------
177-
xmin: int,
177+
xmin: int,
178178
Lower bound for the x-axis constraint
179179
xmax : int,
180180
Upper bound for the x-axis constraint
@@ -187,7 +187,7 @@ def getConstraindSensorsIndices(xmin, xmax, ymin, ymax, nx, ny, all_sensors):
187187
188188
Returns
189189
-------
190-
idx_constrained : np.darray, shape [No. of constrained locations]
190+
idx_constrained : np.darray, shape [No. of constrained locations]
191191
Array which contains the constrained locationsof the grid in terms of column indices of basis_matrix.
192192
"""
193193
n_features = len(all_sensors)
@@ -232,7 +232,6 @@ def functionalConstraint(position, func_response,func_input, freeTerm):
232232

233233

234234
if __name__ == '__main__':
235-
pass
236235
faces = datasets.fetch_olivetti_faces(shuffle=True)
237236
X = faces.data
238237

@@ -278,16 +277,16 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
278277

279278
all_sensors = model.get_all_sensors()
280279

281-
##Constrained sensor location on the grid:
280+
##Constrained sensor location on the grid:
282281
xmin = 20
283282
xmax = 40
284283
ymin = 25
285284
ymax = 45
286-
sensors_constrained = getConstraindSensorsIndices(xmin,xmax,ymin,ymax,nx,ny,all_sensors) #Constrained column indices
285+
sensors_constrained = getConstraindSensorsIndices(xmin,xmax,ymin,ymax,nx,ny,all_sensors) #Constrained column indices
287286

288287
# didx = np.isin(all_sensors,sensors_constrained,invert=False)
289288
# const_index = np.nonzero(didx)
290-
# j =
289+
# j =
291290

292291

293292
##Plotting the constrained region

0 commit comments

Comments
 (0)